使用 gfortran 编译:对 iargc_ 的未定义引用 [英] Compiling with gfortran: undefined reference to iargc_

查看:45
本文介绍了使用 gfortran 编译:对 iargc_ 的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Fedora 20 x86_64 上使用 gfortran [GNU Fortran (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)] 来编译一堆 Fortran 77 代码,这些代码在方式如下:

I'm using gfortran [GNU Fortran (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)] on a Fedora 20 x86_64 to compile a bunch of Fortran 77 code which refers to 'iargc' function in the following manner:

bin2D2nc.f:31: 整数 iargc,strlen1

bin2D2nc.f:31: integer iargc,strlen1

bin2D2nc.f:32: 外部 iargc,strlen1

bin2D2nc.f:32: external iargc,strlen1

bin2D2nc.f:44: i=iargc()

bin2D2nc.f:44: i=iargc()

当 make 脚本到达下面的编译命令时,

When the make script reaches the compilation comand bellow,

gfortran -O3 -ffixed-line-length-132 -fall-intrinsics -I/home/santiago/Install/netcdf_sam/include   -o bin2D2nc -I./SRC ./SRC/bin2D2nc.f ./SRC/hbuf_lib.f ./SRC/cape.f ./SRC/cin.f -L/home/santiago/Install/netcdf_sam/lib  -lnetcdf -L/usr/lib64 -lpthread

我收到这些消息:

bin2D2nc.f:(.text+0x14): undefined reference to `iargc_'

bin2D2nc.f:(.text+0x14): undefined reference to `iargc_'

collect2: 错误:ld 返回 1 个退出状态

collect2: error: ld returned 1 exit status

make: ** [bin2D2nc] 错误 1

make: ** [bin2D2nc] Erro 1

我不是此代码的作者.据我所知,我在 makefile 中正确设置了库路径.

I'm not the author of this code. As far as I know, I set up correctly the library paths in the makefile.

我发现 'iaargc' 是与 GNU Fotran 77 向后兼容的例程,但我对它的理解并不深入.

I have found that 'iargc' is a routine for backward compability with GNU Fotran 77, but I don't understand it deeply.

有人可以提出一些建议来解决这个问题吗?

Could someone give some advise to surpass this problem?

推荐答案

问题和修复 FORTRAN IV 警告:参数的数量与 intrinsinc 过程不兼容,假设为外部"",但不同之处在于另一个问题存在一个外部函数并且与内在函数的相似性是无意的,但您是故意调用内在函数.

The problem is very similar to Fixing FORTRAN IV warning: "The number of arguments is incompatible with intrinsinc procedure, assume 'external' " but the difference is that in the other question there was an external function present and the similarity with an intrinsic was inadvertent, but you are calling the intrinsic on purpose.

声明

EXTERNAL IARGC

意味着 IARGC 在 FORTRAN 66 中是外部或内部函数,但在现代 Fortran" 77 及更高版本中意味着它只是外部函数.

meant that IARGC is an external or an intrinsic function in FORTRAN 66, but in "modern Fortran" 77 and later it means that it is an external function only.

但是你需要调用内部函数https://gcc.gnu.org/onlinedocs/gfortran/IARGC.html .

But you need to call the intrinsic function https://gcc.gnu.org/onlinedocs/gfortran/IARGC.html .

你应该使用

 INTRINSIC IARGC

甚至只是从 EXTERNAL 语句中删除 IARGC,而不添加任何其他内容.然后编译器将停止搜索不存在的外部函数并使用内部函数.

or even just delete IARGC from the EXTERNAL statement without adding anything else. The compiler will then stop searching for a non-existent external function and will use the intrinsic.

最后一点,IARGC 本身不是标准的 Fortran,但在这里应该无关紧要.

A final note, IARGC itself is not standard Fortran, ut it shouldn't matter here.

这篇关于使用 gfortran 编译:对 iargc_ 的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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