g++: create a shared library (.so) with static glibc?

我与影子孤独终老i 提交于 2021-01-29 10:32:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!