This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Static compilation to generate shared library
- From: Ian Lance Taylor <iant at google dot com>
- To: ccodehelp <iitb dot ankit at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 16 Jul 2007 17:08:49 -0700
- Subject: Re: Static compilation to generate shared library
- References: <11605239.post@talk.nabble.com>
ccodehelp <iitb.ankit@gmail.com> writes:
> gcc -c -static logger.c
> gcc -c -static func_lib.c
-static is a link time option. -c tells the compiler to not link. So
using -static and -c together does not make sense.
> gcc -static -Wall -o2 -fPIC -shared -ldl -g -o libfuncs.so logger.o
> func_lib.o
-static says to do a static link. -shared says to make a shared
library, which is inherently non-static. Using -static and -shared
together does not make sense.
> But this is not doing what I want. My intention is to make libfuncs.so such
> that it does not depend on any other libraries like libc.so etc that is all
> the byte code from there is also present in this.
Use -nodefaultlibs to avoid linking against -lc. Also look at using
attributes for symbol visibility.
Ian