This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Is it safe to use "-shared-libgcc" when building a shared library with gcc ?
- From: <duncan dot loveday at bt dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Sat, 28 May 2011 16:52:19 +0100
- Subject: Is it safe to use "-shared-libgcc" when building a shared library with gcc ?
Hi,
gcc allows me to create a shared library and still statically link libgcc but is that a safe thing to do ?
Often, statically linking code into a shared library is unsafe because the code in the static library is not position independent. Does the static version of libgcc contain position independent code ?
My command line is below for reference. Ignore the fact that the output library is also supplied as a -l to the linker, that is a quirk of the makefiles used.
gcc -static-libgcc -shared -fPIC -Wl,+h -Wl,libdb-4.5.sl -Wl,+b -Wl,/usr/local/BerkeleyDB.4.5/lib -o .libs/libdb-4.5.sl <list of object files> -lpthread -lc
Thanks,
Duncan.