How to compile app to work on several Glibc versions

c++, dynamic-linking, glibc

Solution

The easiest way is to build on a machine with the oldest glibc among those you're going to support. With linux machines, you may even take a complete installation and transfer it into a `chroot`ed environment on your machine: this way, there is no need to downgrade your workplace.

I would be glad to see a more convenient solution in other answers (if it will be more convenient indeed: anything involving GCC rebuild doesn't qualify, IMHO).

Problem

How can i compile application to work on all 2.X Glibc versions? Now i compile on machine with 2.7 GLibc version, but when i start app where glibc version is 2.5, i have an error: ``` ./server: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by ./server) ``` How can i compile app that will work on all 2.X versions? Compile command: ``` g++ -o newserver test.cpp ... -lboost_system -lboost_thread -std=c++0x ``` Thanks!

Original source