Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gfortran不编译简单的';世界你好';程序_Fortran_Gfortran - Fatal编程技术网

Gfortran不编译简单的';世界你好';程序

Gfortran不编译简单的';世界你好';程序,fortran,gfortran,Fortran,Gfortran,我有一个让我发疯的问题。我刚刚干净地安装了Ubuntu18.04LTS,并成功地安装了VS代码和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

我有一个让我发疯的问题。我刚刚干净地安装了Ubuntu18.04LTS,并成功地安装了VS代码和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的新手,在诸如“安装库”或类似的解决方案方面,我不能没有任何人一步一步地解释我……我希望你能帮我解决这个问题。

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

欢迎。我建议接受欢迎。您是如何安装gfortran的。只是好奇,因为它通常被称为gfortran:而不是gfortran-9。我只是用sudo来安装gfortran-9。但无论如何,我甚至只安装了gfortran。错误保持不变……在这种情况下,PTRK是正确的,但您的描述令人困惑。你确定它真的给了你对main'`错误的
undefined引用吗?我不希望出现这种情况,因为编译的程序确实包含
main
。问题是我试图“编译”一个可执行文件,因为我认为要执行的命令是
gfortran namefile.exe
。如果你尝试这样做,你会得到我在问题中发布的错误。我确信这一点,因为我试着用另一台18.04的pc做同样的事情,结果是一样的。但老实说,我不知道为什么它说“未定义对main的引用”而不是“无法编译.exe文件”