g++ / CC compatibility

Nevenka Bierny NBierny@quova.com
Wed May 16 18:31:00 GMT 2001


I'm trying to build a static library using g++, which I can then use to
build an executable using CC (clients who compile using our library may not
have g++).

If I build the static library using the following commands:
	g++ -c *.cpp
	ar -r libtest.a *.o

and try to compile an executable using the following commands:
	CC -o SimpleTest SimpleTest.cpp -L. -lsocket -lnsl -lrt -ltest

I get "undefined symbol" errors for symbols which are in libg++
(__builtin_delete, etc).



I can get around this problem by building a shared library using the
following commands:
	g++ -c *.cpp
	g++ -shared -o libtest.so *.o -L. -lpthread -lthread -lsocket -lnsl
-lnrt -ltest
	and add the path for libtest.so to LD_LIBRARY_PATH.

However, speed is of importance, milliseconds do matter, therefore we would
rather build a static library which can then be used to build an executable
using CC or g++.


Is there any way to build a static library using g++ rather than a shared
one?

Thanks.



More information about the Gcc-bugs mailing list