Gfortran 不会编译一个简单的 'hello world' 程序

Gfortran does not compile a simple 'hello world' program

我遇到了一个让我抓狂的问题。我刚刚全新安装了 UBUNTU 18.04 LTS,并成功安装了 VS Code 和 gfortran-9。问题是我无法编译一个简单的 hello world 程序。

该文件保存为 hello.f90,我尝试以多种方式编译它,例如:

`gfortran-9 hello.f90 -o hello.exe

`gfortran-9 hello.exe

或使用目标文件。我总是以同样的错误结束:

/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status

代码很简单:

program hello
implicit none
print *, 'hello world'
end program hello

我在互联网上到处搜索,但由于我是 ubuntu 的新手,所以当涉及到解决方案时,例如:"installing libraries" 或类似的解决方案,如果没有任何人解释,我无法继续下去我一步一步...我希望你。

我解决了。基本上我试图用命令 gfortran namefile.exe 执行可执行文件,但后来我意识到也许我应该使用命令 ./namefile.exe 并且事实上它起作用了。所以编译过程还好,执行错的是我