How can I know if my executable will also to run on other computers (linux)?

我是研究僧i 提交于 2019-12-12 15:12:25

问题


I have an executable I want to be able to distribute and run in other Linux systems. Is there a way to be reasonably sure if this will work, without access to the final runtime environment?

For example, I am concerned my executable could be using a dynamic library that is only present on my development machine.


回答1:


Supply any relevant shared libraries with the executable, and set $LD_LIBRARY_PATH in a shell script that invokes the executable to tell the linker where to find the shared libraries. See the ld.so(8) man page for more details, and be sure to follow the appropriate licenses.




回答2:


Take a look at the Debian (.deb) and Redhat (.rpm) packaging stuff. This is the installer for your package. They aren't all that difficult, and you can tell it to reference other packages that have the required shared objects.

The packaging tools can usually repair packages that are missing libraries and so on. It will also help you place your binaries in such a way that you don't need to set LD_LIBRARY_PATH or put a shell-script front end on your executable.

They aren't that difficult to learn either. Spend a day playing with each and you'll get a passable installer package.




回答3:


Is there a way to be reasonably sure if this will work, without access to the final runtime environment?

One's environment could be a different architecture than yours, even while it stays Linux. Therefore, the only sure way to get your program to the widemost audience is to ship source code.




回答4:


Couldn't you just statically linking everything into a supper massive black hole^W^W binary do the trick?



来源:https://stackoverflow.com/questions/6338490/how-can-i-know-if-my-executable-will-also-to-run-on-other-computers-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!