I guess the issue is called "binary compatibility" (there's a tag on stack overflow devoted to these problems). When you link a binary on a machine, the surrounding environment affects the binary, and, having been run on another machine, it still tries to find the environment similar to the one it was compiled in.
Tolerance to different environments in this case is called binary compatibility.
How does it work?
The key point here is that, even if you specify the same options to linker on different machines, you may still get different binaries. For example, if you link your binary against a shared library with -lfoo
, the exact version of foo
you have on the machine you build on (for example, libfoo.so.5
) is hardcoded into the binary. When it's run on machine B
, it may only contain libfoo.so.4
, and the binary will refuse to run because it needs the missing libfoo.so.5
so file. That's why recompilation helps, and without it it doesn't work.
Ubuntu packages—and these of any other distribution—are all compiled in the same environment (of each other). That's why they install well. And distribution vendors watch that each next version is backwards-compatible with previous ones.
What should I do?
If you want to make your software compatible with different distributions, it's easier than you thought. First, try to compile your application at the oldest distribution possible. Since, as I mentioned before, modern distributions are usually backwards compatible, your soft will, most likely, run on newer distros without problem.
To check the resultant package more thoroughly and get more advice about compatibility, you may from our free Linux Application Checker tool. You might also be interested in generic tips for packaging Linux soft.