提问人:Grant Meadows 提问时间:10/11/2023 最后编辑:hbhbnrGrant Meadows 更新时间:10/12/2023 访问量:109
在 Eclipse 中找不到 GFortran
GFortran not found from make in Eclipse
问:
我正在尝试在 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.
答:
0赞
hbhbnr
10/12/2023
#1
您需要在 Makefile 中设置 GFortran 的正确路径。
就像 Vladimir F Героям слава 所说,您首先需要找出 GFortran 的安装位置。跑
which gfortran
或
type gfortran
在你的壳里。通常的位置是 或 ,但它可能安装在其他地方,例如在某些 macOS 特定路径下或下。由于你的 shell 可以启动它,它必须知道它在哪里。/usr/bin/gfortran
/usr/local/bin/gfortran
/opt
使用您刚刚在 Makefile 中找到的路径。如果直接提及,则添加完整路径。如果没有直接提及,则需要像这样设置变量:gfortran
FC
FC := /usr/bin/gfortran
只需使用您的特定完整路径而不是 ./usr/bin/gfortran
评论