Search code examples
linuxgccglibcabi

target specific glibc ABI


I want to compile a dynamically linked executable on Linux, and I want to target an older glibc ABI to ensure that it can run on as many linux computers as possible. I know that the typical solution to this is to use a chroot or virtual machine, install an old toolchain, and let the toolchain naturally target an older glibc ABI, but I wonder if there is a way to explicitly tell the compiler "Hey, I want you to depend on version GLIBCXX_3.4.11".

Thanks!


Solution

  • Hey, I want you to depend on version GLIBCXX_3.4.11

    Note that GLIBCXX is about libstdc++, and not about glibc.

    The compiler (actually the linker) records required version, such as GLIBCXX_3.4.11, when you link your program against libstdc++.so and use some symbol which has changed in that version.

    The only way you can avoid this is by arranging to link against a different version of libstdc++.so, and that is easiest to achieve via chroot, or by not using the corresponding symbol. So no, you can't just say "I want GLIBCXX_3.4.11".