Reputation: 428
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?
Upvotes: 2
Views: 428
Reputation: 16133
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.
Upvotes: 0
Reputation: 12126
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.
Upvotes: 3
Reputation: 2558
Most platforms have a well-defined ABI that covers C code, but ABIs that cover C++ functionality are not yet common.
A program written in c++ using just libc may not run on another platform. if binary compatibility is an important issue consider using c.
Upvotes: 0
Reputation: 400039
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:
LD_LIBRARY_PATH
variable to make the included versions the preferred ones.dlopen()
and friends, and handle differences in library versions manually.Upvotes: 2