help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: library problem - my own version of C++ using gcc does not link


From: Jim Anderson
Subject: Re: library problem - my own version of C++ using gcc does not link
Date: Thu, 24 May 2007 15:08:26 GMT
User-agent: Thunderbird 1.5.0.8 (X11/20061117)

Paul Pluzhnikov wrote:
Jim Anderson <ezjab@ieee.org> writes:

I tried compiling a C++ program that I have. All of the
C++ files compile ok, but during the linking phase,
I get numerous error messages. The first of which is:

 >>> test.o: In function
 >>> 
`__static_initialization_and_destruction_0':/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/c++/4.1.2/iostream:76:
 >>> undefined reference to `std::ios_base::Init::Init()'

The first question is: what's your failing link line?
Always use correct compiler driver (g++ for C++ code) when compiling
and linking. IOW, do not do this:

  gcc main.cpp

do this instead:

  g++ main.cpp

It looks to me like the libraries are not being found right.

Possible, but less likely than the "user mistake" above.

Cheers,

Paul,

The link line is:

>> gcc -g -o test test.o Product.o DerivedProduct.o Creator.o DerivedCreator.o

I used gcc because when I downloaded g++, the tarball did not
appear to have a complete set of code to build g++.

At one time, didn't gcc compile and link C++ code? I do think it
is strange that gcc will compile C++ code, but not link it.

If I can figure out how to build g++, I'm more than happy to use
g++. I tried using the installed g++ on my system and it linked
the *.o files compiled by gcc just fine. So guess I'm home free.

I appreciate your help but if you can shed light on why gcc
compiles C++ but does not link it, I'm curious to know why.
Personally, I think too much is included in gcc. IMHO, gcc should
compile C files, g++ for C++, etc.

Regards,
Jim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]