Breakdown
Breakdown

Reputation: 1053

How to compile app to work on several Glibc versions

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!

Upvotes: 5

Views: 1437

Answers (2)

Arun
Arun

Reputation: 20383

I am not an expert but it occurs to me that, if the application need to run with glibc 2.5, then it must confine itself to features that are available in 2.5, and nothing thereafter. In other words, restrain using features introduced in 2.6 or later. Will that help?

If you really need features from glibc 2.7, then make it an explicit requirement for the target systems. You can put some code to check the glibc version of the system it is running on and if the available version is lower than the required version, then print/log a comprehensive message and gracefully exit.

However, if you want to cast your net wide, i.e. plan to run your application on wide spectrum of systems, then resorting the usage to a lower version (as sketched in para 1) might turn out to be more fruitful.

Upvotes: 0

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

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 chrooted 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).

Upvotes: 3

Related Questions