How to compile an application to work on multiple versions of Glibc
How can I compile my application to work on all 2.X version of Glibc? Now I am compiling on a machine with version 2.7 of GLibc, but when I run an application where the version of glibc 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 an application that will work in all 2.X versions?
Compile command:
g++ -o newserver test.cpp ... -lboost_system -lboost_thread -std=c++0x
Thank!
source to share
The easiest way is to build a machine with the oldest glibc you intend to support. With Linux devices, you can even do a full installation and move it to chroot
ed on your computer: this way you don't have to downgrade your desk.
I would be happy to see a more convenient solution in other answers (if it is more convenient: anything related to rebuilding GCC is not qualified, IMHO).
source to share
I'm not an expert, but it occurs to me that if an application needs to be run with glibc 2.5, then it should be limited to the functionality available in 2.5, and nothing happens after that. In other words, restrain the use of features introduced in 2.6 or later. Will it help?
If you really need functions from glibc 2.7, make it an explicit requirement for the target systems. You can put some code to check the version of glibc of the system it is running on and if the available version is lower than the required version, then print / write down a comprehensive message and exit gracefully.
However, if you want to use your network as a whole, that is, you plan to run your application on a wide variety of systems, then using use in a lower version (as stated in paragraph 1) may prove to be more fruitful.
source to share