[英]How can I setup linux to compile FORTRAN code into windows binaries?
I'm working on a FORTRAN project and I would like to build all of the binaries that I want to maintain on a linux machine that is dedicated for automated builds.我正在开发一个 FORTRAN 项目,我想在专用于自动构建的 linux 机器上构建我想要维护的所有二进制文件。 I have successfully used mingw to build 32-bit and 64-bit binaries from C source for windows machines on the linux machine with the following packages on Ubuntu. I have successfully used mingw to build 32-bit and 64-bit binaries from C source for windows machines on the linux machine with the following packages on Ubuntu.
apt-get install mingw32
apt-get install mingw-w64
Then I run the following commands to actually compile:然后我运行以下命令来实际编译:
gcc -b amd64-mingw32msvc -V 4.4.4 -o <...other options>
However, the mingw packages that I've obtained via apt-get do not include FORTRAN compilers.但是,我通过 apt-get 获得的mingw包不包括 FORTRAN 编译器。
Anybody got any ideas on what I can do?有人对我能做什么有任何想法吗?
I know this is an old thread but a few things seem to have changed and people might still be interested in the topic.我知道这是一个旧线程,但有些事情似乎已经改变,人们可能仍然对该主题感兴趣。
Problem: I want to use my linux machine to compile some code and create a.exe that I can send to people using Windows.问题:我想用我的 linux 机器编译一些代码并创建一个我可以发送给使用 Windows 的人的.exe。
Solution: Essentially here: http://mxe.cc/解决方案:基本上在这里:http://mxe.cc/
What I did:我做了什么:
git clone -b stable https://github.com/mxe/mxe.git
It will download a few small things and create the directory "mxe" (probably in your home folder)它将下载一些小东西并创建目录“mxe”(可能在您的主文件夹中)
cd into that mxe directory and run "make". cd 进入那个 mxe 目录并运行“make”。 HOWEVER: this would take hours and take up a few GB on your hard drive so instead run something like但是:这将花费数小时并在您的硬盘驱动器上占用几 GB,因此请运行类似
make mpfr eigen opencsg cgal qt
For more ideas on how to shorten that all see this or the mxe tutorial or somewhere else;)有关如何缩短所有内容的更多想法,请参阅此或 mxe 教程或其他地方;)
The easiest way to compile stuff then seems to be something like:编译东西的最简单方法似乎是:
~/mxe/usr/bin/i686-pc-mingw32-gfortran -c main.f95
~/mxe/usr/bin/i686-pc-mingw32-gfortran main.o -o outfile.exe
Of course you can chose something other than fortran, just consult the mxe/usr/bin to see what its called.当然你也可以选择 fortran 以外的东西,只要参考 mxe/usr/bin 看看它叫什么。
if you got mingw32 and the Gnu C cross compiler is working for you... when why not just get the Gnu Fortran cross compiler, too?如果你有 mingw32 和 Gnu C 交叉编译器正在为你工作......为什么不直接获得 Gnu Fortran 交叉编译器呢?
http://www.nber.org/sys-admin/mingw32-fortran-fedora.html http://www.nber.org/sys-admin/mingw32-fortran-fedora.html
EXAMPLE apt-get install mingw32-gcc-fortran
You can always download and install a prebuilt compiler from the MinGW(-w64) project itself:您始终可以从 MinGW(-w64) 项目本身下载并安装预构建的编译器:
Windows 64-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.6.2-1/ Windows 32-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/ Windows 64-bit: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.6.2-1/ Windows 32-bit: http://sourceforge. net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/
Just unpack somewhere and add the cross*/bin
directory to PATH.只需在某处解压缩并将cross*/bin
目录添加到 PATH。
I include (obj)c(++) and fortran.我包括 (obj)c(++) 和 fortran。
On Ubuntu 18.04 I use在 Ubuntu 18.04 我使用
apt install gfortran-mingw-w64
Then use the compiler x86_64-w64-mingw32-gfortran
in place of gfortran
.然后使用编译器x86_64-w64-mingw32-gfortran
代替gfortran
。 If you're using cmake, you can configure the compiler from the build directory like so:如果您使用 cmake,您可以从构建目录配置编译器,如下所示:
FC=x86_64-w64-mingw32-gfortran cmake ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.