您没有提到在编译过程中遇到的错误。见this link。具体做法是:
-std=*std*
其中STD可以是“f95的”,“F2003”,“F2008”,“GNU”,或“传统”中的一个。该
Default value for std is ‘gnu’. From the same page: The ‘legacy’ value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs. The ‘f95’, ‘f2003’ and ‘f2008’ values specify strict conformance to the Fortran 95, Fortran 2003 and Fortran 2008 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the Fortran 77 features that are permitted but obsolescent in later standards.
例如,如果你有一个文件old_fortran.f77编译,你可以这样做:
gfortran -std=legacy old_fortran.f77 -o a.out
其中-o a.out给你的可执行a.out。我已成功使用此编译器的较旧版本,而无需使用此选项。尽管如此,您可能会收到一些警告。第一次尝试:
gfortran old_fortran.f77 -o a.out
编辑:在OP看下面的评论后,它看起来像可能涉及不同的问题。这可能是你的安装有问题(这是可能的),或者你的设备搞砸了。我认为你的路径中的链接器(ld)是32位,并且由编译器创建的目标文件可能是64位。只是一种预感。你可以发布输出
which ld
假设返回:/ path/to/ld。然后采取该输出,并做
file /path/to/ld
你可以张贴这两个命令的输出作为评论?