fortran - 运行简单的 hello_world 程序时出错
问题描述
我需要下载 Fortran 来完成我的项目。我曾尝试关注 youtube 上的视频(https://www.youtube.com/watch?v=HakTEhU3Q9U),但最后我得到了一个错误。我无法编译一个简单的“hello_world”程序。
我是编程新手,所以我不熟悉计算术语。我已经下载了 java、Eclipse 和 Fortran。当我打开 Eclipse 并尝试编译一个简单的程序时,我得到一个错误。
make all
Building file: ../helloFortran.f95
/bin/sh: gfortran: command not found
Invoking: GNU Fortran Compiler
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -o "helloFortran.o" "../helloFortran.f95"
make: *** [helloFortran.o] Error 127
"make all" terminated with exit code 2. Build might be incomplete.
17:00:47 Build Failed. 2 errors, 0 warnings. (took 94ms)
我要运行的程序就是这个。
program helloFortran
implicit none
print*, "Fortran is great"
end program helloFortran
我还有一个文本文件,我不知道它是做什么用的。
#!/bin/bash
PATH=$PATH:/usr/local/gfortran/bin
$HOME/eclipse/parallel-2018-12/Eclipse.app/Contents/MacOS/
eclipse -data $HOME/documents/workspace
解决方案
确保文件EclipseFortran.sh
包含
#!/bin/bash
PATH=$PATH:/usr/local/gfortran/bin $HOME/eclipse/parallel-2018-12/Eclipse.app/Contents/MacOS/eclipse -data $HOME/documents/workspace
PATH 行是单行,最多workspace
. 然后,输入
bash EclipseFortran.sh
这应该会在知道 gfortran 位置的情况下启动 eclipse。
以这种方式设置环境有点不寻常。您可以在 Mac OS 上为 GUI 应用程序定义环境变量。我没有使用 Mac OS,所以我可以建议查看https://stackoverflow.com/a/3756674/3327666
launchctl setenv PATH $PATH:/usr/local/gfortran/bin
推荐阅读
- excel - 使用 Apache POI 强制关闭 Excel 电子表格?
- angular - Angular html模板中的VS Code误报错误
- arrays - 如何显示来自json文件+服务器的单元格标题?
- python - Plotly 表达折线图标记特定点并保留悬停数据
- arrays - 显示/隐藏 array.map() reactJS 的一项
- docker-compose - 使用 solrcloud 对地理空间操作进行分片收集后性能下降
- python - 如何更改输入框用户输入
- javascript - 身份验证不适用于使用 NodeJS 进行的谷歌云 API 身份验证
- testing - 使用 Gherkin 如何最好地详细说明 BDD 测试中的预期结果?
- javascript - 为什么 JavaScript 中的数组长度在添加属性后不会改变?