无法通过终端在 macOS 上安装 Fortran 程序

Cannot install fortran program on macOS via Terminal

当我在终端中 运行 make 时,出现以下错误:

    gfortran: warning: couldn’t understand kern.osversion ‘15.6.0 
    gfortran  -O1  -I..    -DFLUSH  -c ../aocn2.f90

关于如何为 macOS 安装 fortran 有什么想法吗?

恕我直言,在 macOS/OSX 下安装 Fortran 的最简单方法是通过 homebrew.

首先,转到 App Store 并安装 Apple 的 Xcode。您可以通过输入 space 并开始输入 App Store 然后在猜对后点击 Enter/ReturnXcode 看起来像这样:

然后启动一个终端,使用 space 终端 Enter/Return 并在终端中完成其余的工作。

安装 "Xcode command line tools":

xcode-select --install

然后安装 homebrew,方法是转到 homebrew website 并在那里复制和粘贴单行代码。

然后安装 GCC ("GNU Compiler Collection") 其中包括 gfortran:

brew install gcc

您需要将 PATH 设置为包含 /usr/local/bin,这是 homebrew 安装程序的地方:

export PATH=/usr/local/bin:$PATH

您现在可以 运行:

gfortran someFile.for