[plug] gcc toolchain problem

Carl Gherardi carl.gherardi at gmail.com
Thu Mar 24 17:40:18 WST 2005


Hey all,

Got a with linking to a library dynamically when I dont want it too.

nought.c
main () { exit(0); }

#gcc -o nought nought.c
#ldd nought
        libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
(What I expect)
#gcc -o nought nought.c -lm
#ldd nought
        libm.so.6 => /lib/tls/libm.so.6 (0x40025000)
        libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

It puts a link stub for libm in the binary, even though libm is never
referenced in the program. So I cant run the above program on a
machine without libm even though it clearly doean't use it. (I know
libm is likely on most systems, but the situation I have is with more
obscure libraries)

I know i've told it to link libm, I figure there must be a way for the
gcc toolchain to only create dynamic links in the resulting binary iff
the binary calls functions from within it, but cant figure out how.

Any ideas?

Carl G



More information about the plug mailing list