Static compilation to generate shared library
Ian Lance Taylor
iant@google.com
Tue Jul 17 00:09:00 GMT 2007
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
More information about the Gcc-help
mailing list