如何设置 Linux 将 FORTRAN 代码编译为 Windows 二进制文件?
我正在开发一个 FORTRAN 项目,我想在专门用于自动化构建的 Linux 机器上构建我想要维护的所有二进制文件。我已成功使用 mingw 在 Linux 计算机上使用 C 源代码为 Windows 计算机构建 32 位和 64 位二进制文件,并在 Ubuntu 上使用以下软件包。
apt-get install mingw32
apt-get install mingw-w64
然后我运行以下命令来实际编译:
gcc -b amd64-mingw32msvc -V 4.4.4 -o <...other options>
但是,我通过 apt-get 获得的 mingw 软件包不包含 FORTRAN 编译器。
有人对我能做什么有什么想法吗?
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. 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.
Anybody got any ideas on what I can do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您有 mingw32 并且 Gnu C 交叉编译器正在为您工作...为什么不也获得 Gnu Fortran 交叉编译器呢?
http://www.nber.org/sys-admin/mingw32-fortran -fedora.html
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?
http://www.nber.org/sys-admin/mingw32-fortran-fedora.html
我知道这是一个旧线程,但有些事情似乎已经改变,人们可能仍然对这个主题感兴趣。
问题:我想使用我的 Linux 机器编译一些代码并创建一个 .exe,我可以将其发送给使用 Windows 的人。
解决方案:基本上在这里:http://mxe.cc/
我做了什么:
git clone -b stable https://github.com/mxe/mxe.git
它将下载一些小东西并创建目录“mxe”(可能是在你的主文件夹中)
cd进入该 mxe 目录并运行“make”。但是:这将需要几个小时并占用您的硬盘驱动器上的几GB,因此请运行类似的东西
make mpfr eigen opencsg cgal qt
有关如何缩短时间的更多想法,请参阅 此 或mxe 教程或其他地方;)
编译内容的最简单方法似乎是这样的:
~/mxe/usr/bin/i686-pc-mingw32-gfortran -c main.f95
~/mxe/usr/bin/i686-pc-mingw32-gfortran main.o -o outfile.exe
当然你可以选择fortran以外的东西,只要查阅mxe/usr/bin就可以了它叫什么。
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.
Solution: Essentially here: 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)
cd into that mxe directory and run "make". HOWEVER: this would take hours and take up a few GB on your hard drive so instead run something like
make mpfr eigen opencsg cgal qt
For more ideas on how to shorten that all see this or the mxe tutorial or somewhere else ;)
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.
您始终可以从 MinGW(-w64) 项目本身下载并安装预构建的编译器:
Windows 64 位: http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/4.6.2-1/
Windows 32 位:http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.6.2-1/
只需在某处解压并添加
cross*/bin
目录到 PATH。我包括 (obj)c(++) 和 fortran。
You can always download and install a prebuilt compiler from the MinGW(-w64) project itself:
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.I include (obj)c(++) and fortran.
在 Ubuntu 18.04 上,我使用
然后使用编译器 x86_64-w64-mingw32-gfortran 代替 gfortran。如果您使用 cmake,则可以从构建目录配置编译器,如下所示:
On Ubuntu 18.04 I use
Then use the compiler
x86_64-w64-mingw32-gfortran
in place ofgfortran
. If you're using cmake, you can configure the compiler from the build directory like so: