vscode配置Fortran报错

已配置launch.json和tasks.json


PS C:\Users\16134\Desktop\约化重力
> cd "c:\Users\16134\Desktop\约化重力\" ; if ($?) { gfortran hello.f90 -o hello } ; if ($?) { .\hello }
gfortran : The term 'gfortran' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:47
+ cd "c:\Users\16134\Desktop\约化重力\" ; if ($?) { gfortran hello.f90 -o h ...
+                                               ~~~~~~~~   
 + CategoryInfo          : ObjectNotFound: (gfortran:String) [], CommandNotFoundException    
+ FullyQualifiedErrorId : CommandNotFoundException

看起来是 gfortran 未被识别。确认一下:1、是否安装gfortran;2、是否正确配置环境变量。

参考GPT和自己的思路:

根据你提供的信息,错误原因是由于 gfortran 命令无法被识别。这个问题需要检查以下几个地方:

  1. 检查是否已经成功安装了 gfortran 编译器,如果没有安装需要安装。
  2. 确保已正确配置gfortran的环境变量(将 gfortran 的路径添加到 PATH 环境变量中)。
  3. 如果以上两个步骤已经完成,尝试重新启动命令行窗口,然后再次运行命令。

希望这些建议能帮助你解决问题。