This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++ / CC compatibility


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]