This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ / CC compatibility
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Subject: g++ / CC compatibility
- From: Nevenka Bierny <NBierny at quova dot com>
- Date: Wed, 16 May 2001 18:31:26 -0700
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.