Linux distribution binary compatibility

前端 未结 10 1219
日久生厌
日久生厌 2021-01-30 14:23

Any way to make a binary in a Linux distribution and run it on another distribution with same architecture? Or I should compile and build it on different distributions?

相关标签:
10条回答
  • 2021-01-30 14:52

    Statically linking your binaries makes them LESS portable because some libraries won't then work correctly for that machine (differing authentication methods, etc).

    If you statically link any "unusual" libraries and keep your set of supported distros to a minimum, you should be ok.

    Don't statically link the C library (or the whole binary), that's a recipe for trouble :)

    Look at what (e.g.) Google do with Chrome.

    0 讨论(0)
  • 2021-01-30 14:58

    The best way is to distribute the source code and to make it easy to build the source on any reasonable Linux distribution. This is better than binary distribution because it is not enough to make the binary compatible with shared libraries. You also need to make sure you adapt your program to things like distribution specified locations and conventions for where web apps go, or how e-mail is sent, or how services are started, or how to determine the default paper size, or a myriad of other details.

    See for example the Debian Policy Manual for a document describing many of the things a distribution needs to decide to ensure compatibility between applications running on it. You don't need to read it through or learn it by heart, but it shows the scope of the issues that may trip you.

    You should probably work together with several of the major distributions to ensure your application works well with all of them. Most distributions' developers will happily help if you approach them politely. If you're lucky, you can attract volunteers from the distros to make the binary packaging for you, and that will quickly give you feedback on what you need to change at the source level to make your application easy to package.

    The Linux Standard Base already mentioned by others attempts to work out a cross-distribution solution to these variables, but it is not comprehensive and not fully supported by most distributions. However, most distributions consider it a problem if they accidentally break LSB compatibility.

    0 讨论(0)
  • 2021-01-30 15:02

    What language is your application coded in? If its in a language like Python, (and no C bindings) or Java or any other VM based language, then I think you can trust the VM to make sure your application will work on the different Linux distributions.

    Also, there is the Linux Standard Base which you can refer to.

    HTH,Amit

    0 讨论(0)
  • 2021-01-30 15:05

    You could statically link your executables for portability.

    0 讨论(0)
提交回复
热议问题