Reputation: 164
I'm trying to compile libconfig++ version 1.4.8 with
make LDFLAGS='-static-libstdc++ -static-libgcc'
but this doesn't seem to work since I'm still getting:
$ readelf -d lib/.libs/libconfig++.so | grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED) Shared library: [libm.so.6]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1]
I'm noticing that the second-to-last compile step for the so file contains my LDFLAGS:
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -Wall -Wshadow -Wextra -Wno-unused-parameter -version-info 10:3:1 -no-undefined -static-libgc
c -o libconfig++.la -rpath /usr/local/lib libconfig___la-libconfig.lo libconfig___la-scanner.lo libconfig___la-grammar.lo libconfig___la-scanctx.lo li
bconfig___la-strbuf.lo libconfig___la-libconfigcpp.lo
Whereas it appears like the very last one doesn't:
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7
/crtbeginS.o .libs/libconfig___la-libconfig.o .libs/libconfig___la-scanner.o .libs/libconfig___la-grammar.o .libs/libconfig___la-scanctx.o .libs/libc
onfig___la-strbuf.o .libs/libconfig___la-libconfigcpp.o -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linu
x-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/l
ib/gcc/x86_64-linux-gnu/4.7/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.7/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x
86_64-linux-gnu/crtn.o -O2 -Wl,-soname -Wl,libconfig++.so.9 -o .libs/libconfig++.so.9.1.3
Could this be the cause of it, and in that case, how would I go about fixing/working around it?
Upvotes: 2
Views: 6249
Reputation: 71
-static-libgcc is GCC option, not a linker option. Put it in CFLAGS instead.
Upvotes: 1
Reputation: 786
Make sure that you $(LD_FLAGS) are included in you linking call.
On a side note, your linker could be picking up a dynamic (*.so) library that prevents -static-libstdc++ and -static-libgcc to be used. Every library calling libgcc and libstdc++ should be linked statically (if there is a static version available, of course).
Upvotes: 0
Reputation: 2971
It seems like the libconfig++ Makefile is simply ignoring LDFLAGS, since I don't see '-static-libstdc++' being picked up at all.
Try this:
CXX="g++ -static" make
Or just put the LDFLAGS before make, instead of after it.
Upvotes: 1