问题
I'm trying to create a shared library (.so file) that will include its own copy of glibc and link to it statically.
I am already linking to libgcc and libstdc++ statically using -static-libgcc -static-libstdc++
in addition to -shared -fPIC
and it works great.
What combination of flags do I need to set to link to the static version of glibc as well?
I tried adding -static
to the lot but got this error:
/usr/bin/ld: /home/.../x86_64-unknown-linux-gnu/4.6.2/crtbeginT.o:
relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a
shared object; recompile with -fPIC
/home/.../x86_64-unknown-linux-gnu/4.6.2/crtbeginT.o: could not read symbols: Bad value
来源:https://stackoverflow.com/questions/17339828/g-create-a-shared-library-so-with-static-glibc