在High Sierra上安装/编译gfortran时出现问题



我在安装了High Sierra的新Mac mini上使用gfortran编译时遇到了很多问题。

我用自制软件安装了gcc,没有任何错误消息。如果我试图编译一个基本的hello-world代码或一段已经在其他计算机上用gfortran编译并成功运行的代码,我每次都会遇到这个错误(编译gfortran helloworld.f90 -o hw时出现完全错误)。

FATAL:/opt/local/bin/../libexec/as/x86_64/as: I don't understand 'm' flag!

我不理解这个错误,但由于我可以在Sierra上编译和运行相同的代码,我不得不假设这在gfortran/gcc和High Sierra之间不起作用。

我真的很想知道是否有其他人也有同样的问题,或者认为这是由其他原因引起的,并且知道如何解决

编辑:

编译一个基本的helloworld C代码,效果很好。没有错误。

对于gcc -v:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

对于gfortran -v:

Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/7.2.0/libexec/gcc/x86_64-apple-darwin17.0.0/7.2.0/lto-wrapper
Target: x86_64-apple-darwin17.0.0
Configured with: ../configure --build=x86_64-apple-darwin17.0.0 --prefix=/usr/local/Cellar/gcc/7.2.0 --libdir=/usr/local/Cellar/gcc/7.2.0/lib/gcc/7 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-7 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-checking=release --with-pkgversion='Homebrew GCC 7.2.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-nls
Thread model: posix
gcc version 7.2.0 (Homebrew GCC 7.2.0) 

对于as -v:

Apple Inc version cctools-895, GNU assembler version 1.38

但这会被挂断,必须用ctrl+c取消。

我运行的是OS X 10.13.1,并使用自制软件安装了gcc v7.2(两者都使用自制软件网页上的标准说明安装)。Xcode是v9.1和最新版本。我在tcsh窗口中工作,但在bash中测试时也会出现同样的错误。

根据在另一个网页上提到的内容,我已经设法使gfortran的早期版本正常工作。

我通过macports导入了gcc v6.4,其gfortran显然目前在High Sierra上工作。

它并没有解决gcc v7.2和High Sierra的问题,但它提供了一个临时解决方案。

最新更新