在 Eclipse 中的 make 中未找到 GFortran

问题描述 投票:0回答:1

我正在尝试在 Eclipse 中设置 GFortran。我正在使用 macOS。我安装了 GFortran 和 GCC。当我在 Eclipse 中单击“构建项目”时,出现此错误:

10:19:28 **** Build of configuration Debug for project HelloFortran ****
make all 
Building file: ../hello.f90
Invoking: GNU Fortran Compiler
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "hello.o" "../hello.f90"
/bin/sh: gfortran: command not found
make: *** [hello.o] Error 127
"make all" terminated with exit code 2. Build might be incomplete.

10:19:29 Build Failed. 2 errors, 0 warnings. (took 283ms)

我不知道从哪里开始解决这个问题。我的背景不是计算机科学。我正在努力为我要加入的实验室学习 Fortran。

我尝试使用 CLion,但我在该程序中也遇到了相同的错误。

这是我的终端的输出,显示

gcc
gfortran
已安装并可用:

(base) grantmeadowsjr@Grants-Mac ~ % gcc --version
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
(base) grantmeadowsjr@Grants-Mac ~ % gfortran --version
GNU Fortran (Homebrew GCC 13.2.0) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
eclipse macos fortran gnu-make gfortran
1个回答
0
投票

您需要在 Makefile 中设置 GFortran 的正确路径。

就像 Vladimir F Героям слава 所说,你首先需要找出 GFortran 的安装位置。奔跑吧

which gfortran

type gfortran

在你的壳里。通常的位置是

/usr/bin/gfortran
/usr/local/bin/gfortran
,但它可能安装在其他地方,例如
/opt
下或某些 macOS 特定路径下。既然你的 shell 可以启动它,它就必须知道它在哪里。

使用您刚刚在 Makefile 中找到的路径。如果直接提到

gfortran
,则添加完整路径。如果没有直接提到,则需要像这样设置变量
FC

FC := /usr/bin/gfortran

只需使用您的特定完整路径而不是

/usr/bin/gfortran

© www.soinside.com 2019 - 2024. All rights reserved.