Link glibc statically but some other library dynamically with GCC

后端 未结 2 1997
野性不改
野性不改 2020-12-09 05:52

I need to statically link glibc to my project, because the target platform supports only a very old one ( but it works with statically linked glibc from my toolchain, I have

相关标签:
2条回答
  • 2020-12-09 06:12

    There is a -static-libgcc if that may help

    0 讨论(0)
  • 2020-12-09 06:22

    You should be using -static, not -Wl,-static. The latter bypasses gcc's knowledge, and therefore gcc is still trying to link the shared libgcc_s.so rather than the static libgcc_eh.a.

    If your aim is to link libc statically but libpthread dynamically, this is simply not going to work. You cannot mix and match different versions of libpthread; it's part of glibc, just a separate file, and the internals need to match. Even with the same version, I think linking libc statically and libpthread dynamically will be very broken.

    If glibc is too big for your needs, you could try an alternate libc like uClibc or musl.

    0 讨论(0)
提交回复
热议问题