Simpliest solution
There is a several ways how you can deal with this problem. I think the easiest (and solution I choose) is compile application on the most oldest version of OS you want support. Here is the reason:
For dynamic linking, Linux (and most other UNIXes) support backward compatibility: an old binary continues to work on newer systems. But they don’t support forward compatibility (a binary built on a newer system will generally not run on an older one).
External links:
- http://stackoverflow.com/questions/8657908/deploying-yesod-to-heroku-cant-build-statically/8658468#8658468
- http://stackoverflow.com/questions/10815453/compile-with-older-libc-version-glibc-2-14-not-found
- http://stackoverflow.com/questions/4032373/linking-against-an-old-version-of-libc-to-provide-greater-application-coverage/5977518#5977518
Another solutions
Here is a nice list how can be this issue solved (source here):
- You could copy ld-2.14.so (the target of /lib/ld-linux symlink) to the target system, and invoke it explicitly: /path/to/ld-2.14.so –library-path /path/to/your/executable. This generally works, but can confuse an application that looks at argv[0], and breaks for applications that re-exec themselves.
- You could build on an older system.
- You could use appgcc.
- You could set up a chroot environment matching the target system, and build inside that chroot.
- You could build yourself a Linux-to-olderLinux crosscompiler
One more solution
You can also try following way, but I don’t test it
#include <limits.h> #include <stdlib.h> #include <stdio.h> __asm__(".symver realpath,realpath@GLIBC_2.2.5"); int main() { char* unresolved = "/lib64"; char resolved[PATH_MAX+1]; if(!realpath(unresolved, resolved)) { return 1; } printf("%s\n", resolved); return 0; }
For the first solution, I tested whether argv[0] is changed while the executable is invoked by ld-2.14.so explicitly, and the answer is no, argv[0] is still the executable itself.