系统相关
首页 > 系统相关> > linux – gfortran:在64位系统中编译32位可执行文件

linux – gfortran:在64位系统中编译32位可执行文件

作者:互联网

我在AMD Athlon(tm)64 X2双核处理器5200×2上运行Ubuntu 12.10(64位),Linux内核3.5.0-51通用.我有GNU Fortran(Ubuntu / Linaro 4.7.2-2ubuntu1)4.7.2.

我正在尝试将一些代码编译成32位可执行文件.我已经检查过我的系统上安装了所有需要的库(我在以前在32位计算机上编译的程序上运行了ldd,并下载了丢失的软件包).我尝试运行$gfortran foo.f -m32 -L / lib / i386-linux-gnu,但是我收到以下错误:

/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgfortran.so when searching for -lgfortran
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgfortran.a when searching for -lgfortran
/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libquadmath.so when searching for -lquadmath
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libquadmath.a when searching for -lquadmath
/usr/bin/ld: cannot find -lquadmath
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.7/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: returned 1 exit status

我检查了/usr/lib/gcc/i686-linux-gnu/4.7和/usr/lib/gcc/i686-linux-gnu/4.7.2目录,它们都是空的.

你能帮我解决一下这个问题吗?我做了我的研究,但这是我能得到的.

先感谢您!

解决方法:

64位库/usr/lib / gcc / x86_64-linux-gnu / …不适用于32位编译.您需要安装multilib编译器软件包(请参阅https://help.ubuntu.com/community/InstallingCompilers).例如:

sudo apt-get install gfortran-multilib

现在gfortran -m32 foo.f应该可行.

标签:gfortran,32bit-64bit,linux,fortran
来源: https://codeday.me/bug/20190728/1559883.html