Take the 2-minute tour ×

The code is written in c/c++，may depend some libs in the compiling host; and it should run in another host without libs depending problems. Both hosts are linux, may have different versions. Do you have a good strategy?

share|improve this question
maybe it is easy to install the dynamic library that ara necesasary –  logoff Oct 9 '12 at 10:02
add comment

4 Answers

Link the application statically, so that it depends on as few dynamically loaded libraries as possible. This is the general solution to this problem.

Other solutions include:

  • Ship the required libraries with the application, and override the system's LD_LIBRARY_PATH variable to make the included versions the preferred ones.
  • Write code to dynamically load the libraries using dlopen() and friends, and handle differences in library versions manually.
share|improve this answer
add comment

Pure static linking on Linux is discouraged, it's only really possible if you use an alternative libc (such as dietlibc) which isn't an option with C++, my favoured approach is to build the application on the oldest version of Linux you have to support as the newer libc builds will have backwards compatibility.

This will only cover libc, other requirements, such as gtk, pangom, etc will have to be compiled directly into your binary.

share|improve this answer
+1 for compiling on the oldest Linux –  aponomarenko Oct 10 '12 at 7:02
add comment


A program written in c++ using just libc may not run on another platform. if binary compatibility is an important issue consider using c.

share|improve this answer
why do you think a c++ library can not preserve binary compatibility, and c can? –  BЈовић Oct 9 '12 at 11:20
for C++ there are 3 major categories : Itanium C++ ABI, Microsoft ABI and others. you simply can't link against a library with a different ABI than yours. and from my own experience a simple "hello world" executable written on a standard fedora 14 distribution produced "seg fault" on a "debian lenny" (I don't rememer library versions!!) –  arash kordi Oct 9 '12 at 11:44
But the same applies for c. Or am I wrong? –  BЈовић Oct 9 '12 at 12:35
add comment

Take all answers for this question into account (static linking, compiling on the oldest Linux, etc.) and then check your final binary by the Linux App Checker to show compatibility issues with other Linux distributions.

share|improve this answer
add comment

Your Answer


