Static compilation to generate shared library
ccodehelp
iitb.ankit@gmail.com
Tue Jul 17 11:10:00 GMT 2007
Hi,
Thanks for taking time to look at my problem but using -nodefaultlibs
doesn't seem to solve my problem.
See, suppose I have a very simple program case.c and I compile it as: gcc
case.c, I get a.out of size like 10Kilobytes and on
$ ldd a.out
linux-gate.so.1 => (0xffffe000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7dbf000)
/lib/ld-linux.so.2 (0xb7f12000)
now I do gcc -static case.c to a.out of size 526 Kilobyte with
$ ldd a.out
not a dynamic executable
I want my libfuncs.so to show this latter behaviour while as of now it is
showing the former. I want the byte code from the C library to be present in
my executable.
Thanks,
Ankit
Ian Lance Taylor-3 wrote:
>
> 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
>
>
--
View this message in context: http://www.nabble.com/Static-compilation-to-generate-shared-library-tf4083168.html#a11647195
Sent from the gcc - Help mailing list archive at Nabble.com.
More information about the Gcc-help
mailing list