I just want get this portion of the code to compile.

I

Ian Collins

On 05/ 3/12 08:19 PM, Charles Wilson wrote:

The same thing over and over...

Stop posting the same thing over and over!
 
I

Ian Collins

This is what I get


[cwilson@orion Hw7]$ gcc hw7.cpp
/tmp/ccN2xrWu.o: In function `main::._84::._84()':
hw7.cpp:(.text+0x15): undefined reference to `std::basic_string<char,

It looks like your compiler isn't installed correctly (missing standard
library?). These are linker errors.
 
M

Miles Bader

Ian Collins said:
This is what I get

[cwilson@orion Hw7]$ gcc hw7.cpp
/tmp/ccN2xrWu.o: In function `main::._84::._84()':
hw7.cpp:(.text+0x15): undefined reference to `std::basic_string<char,

It looks like your compiler isn't installed correctly (missing
standard library?). These are linker errors.

This sort of error often results from using "gcc" instead of "g++" to
compile a C++ program. "gcc" knows how to compile a C++ file to an
object file (because each source file ends in ".cpp"), but when
invoking the linker, doesn't realize that it should link with C++
libraries; using "g++" explicitly tells the driver that it should do
that.

Try using "g++ hw7.cpp" instead.

-Miles
 
C

Charles Wilson

Ian Collins said:
This is what I get
[cwilson@orion Hw7]$ gcc hw7.cpp
/tmp/ccN2xrWu.o: In function `main::._84::._84()':
hw7.cpp:(.text+0x15): undefined reference to `std::basic_string<char,
It looks like your compiler isn't installed correctly (missing
standard library?).  These are linker errors.

This sort of error often results from using "gcc" instead of "g++" to
compile a C++ program.  "gcc" knows how to compile a C++ file to an
object file (because each source file ends in ".cpp"), but when
invoking the linker, doesn't realize that it should link with C++
libraries; using "g++" explicitly tells the driver that it should do
that.

Try using "g++ hw7.cpp" instead.

-Miles

OMFG THAT WAS IT I WAS USING gcc NO fin wonder. Ok i am going to
smash my head against a wall.

Thanks
 
G

Guest

On Thursday, May 3, 2012 9:04:43 AM UTC+1, Charles Wilson wrote:

if posting the same thing over and over again is supposed to attract my attention. Don't do it.
 
G

Guest

if I put cstring in I got a compilation error. If I put string in I didn't.

well, its usually a good idea not to use
using namespace std;
but I was assuming it was masking a std::string not defined diagnostic (I never use "using namespace std;") but i was mistaken. On Visual C++ anyway.

this line

gave this error
I am not sure if i am understanding you. Forgive me I am a noob. on
all the programs i have created i have used "using namespace std;"
without a problem. How does the namespace effect the string?

<snip>

this is cut down version of the program I used to find the bug

#include <fstream>
#include <cstring>

int main ()
{
struct{int chronum;std::string pname;int next;}
plist[50],temp;
std::ifstream fin;
fin.open("pres.dat");
fin >> plist[n].pname;
return 0;
}

is it really necessary to put the struct definition all on one line? Some blank lines would have been nice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top