This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Static compilation to generate shared library


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


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