fortran链接错误 [英] fortran link error

查看:114
本文介绍了fortran链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用gfortan编译器编译fortran程序时遇到问题. 主程序位于main.f中.所以,我在控制台中编写:

I have a problem with compiling a fortran program with the gfortan complier. The main program is located in main.f. So, I write in console:

gfortran D:\test\test.f

但是它显示了很多错误,例如:

But it displays me a lot of errors such as:

 C:\Users\Efds~1\AppData\Local\Temp\cchFNGgc.o:test.f:<.test+0x3a>: undefined reference to '_gridw_'
 C:\Users\Efds~1\AppData\Local\Temp\cchFNGgc.o:test.f:<.test+0x3a>: undefined reference to '_gridz_'
 etc.

我认为是由于功能gridwgridz等位于其他* .f文件中.但是我不知道如何将所有这些链接在一起.

I think it's because of functions gridw, gridz etc. are located in other *.f files. But I don't know how to link these all together.

此外,我尝试使用Compaq Visual Fortran编译器,但并没有帮助我.

Also, I tried to use Compaq Visual Fortran Complier, but it didn't help me.

推荐答案

将多个源文件编译并链接到一个可执行文件中的基本命令是

A basic command for compiling and linking multiple source files into one executable would be

gfortran -o executable source1.f source2.f source3.f

请注意,您指定的任何.f文件都将在其依赖的任何其他源文件的右边命名.编译器的文档中对此进行了详尽的介绍.

taking care that any .f file you specify is named to the right of any other source files on which it depends. All of this, and much more besides, is well covered in the compiler's documentation.

这篇关于fortran链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆