简体   繁体   English

在Linux上编译一个fortran程序并将可执行文件移至另一台Linux机器

[英]Compiling a fortran program on linux and moving the executable to another linux machine

I have a code that I have written in Fortran during my PhD, and now I am collaborating with some researcher that uses Linux, and they need my model, that is basically a single executable file. 我有一个在博士期间用Fortran编写的代码,现在我正在与一些使用Linux的研究人员合作,他们需要我的模型,基本上是一个可执行文件。 In the future I will probably make it open source, but up to know they just want the executable, also because they are not programmers and they have never compiled a program in their life. 将来,我可能会将其开源,但要知道他们只想要可执行文件,这还因为他们不是程序员,并且一生中从未编译过程序。 So the question is: is it possible to compile it on my linux machine and then send it to them in order to use it in another linux machine?Or does the linux version and distribution matter? 所以问题是:是否可以在我的linux机器上编译它,然后将其发送给他们以便在另一台linux机器上使用它?或者linux版本和发行版很重要吗? thank you very much A. 非常感谢你A.

If you do not use many libraries you can do that. 如果您不使用许多库,则可以这样做。 One option is statically linking the executable ( -static or similar compiler option). 一种选择是静态链接可执行文件( -static或类似的编译器选项)。 You need to have the static versions of all needed libraries for that. 您需要为此拥有所有所需库的静态版本。 The have .a suffix. 后缀为.a They are often not installed by default in Linux distributions and often they are not supplied in the repositories at all. 默认情况下,它们通常没有安装在Linux发行版中,并且通常根本没有在存储库中提供它们。

In my distrbution (OpenSuSE) they are in packages like glibc-devel-static , lapack-devel-static and similar. 在我的发行版(OpenSuSE)中,它们位于glibc-devel-staticlapack-devel-static类的软件包中。

The other option would be to compile the executable on a compatible distribution the users will have (GLIBC version is important) and supply all .so dynamically linked libraries they will need with your executable. 另一种选择是在用户将拥有的兼容发行版上编译可执行文件(GLIBC版本很重要),并为可执行文件提供所需的所有.so动态链接库。

All of this assumes you use the same platform, like i586 or amd64 or arm like wallyk comments. 所有这些都假定您使用相同的平台,如i586amd64arm如wallyk注释。 I mostly assumed you are on a PC. 我通常以为您在PC上。 You can force most compilers to produce a 32-bit or 64-bit executable by -m32 or -m64 option. 您可以通过-m32-m64选项强制大多数编译器生成32位或64位可执行文件。 You need the right version of the development libraries for that. 为此,您需要正确版本的开发库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM