Re: Static compilation to generate shared library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ccodehelp <iitb.ankit@xxxxxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux