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

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

问题描述

我在Fedora 20 x86_64上使用gfortran [GNU Fortran(GCC)4.8.3 20140911(Red Hat 4.8.3-7)]来编译一堆Fortran 77代码,该代码引用了'iargc'函数以下方式:


bin2D2nc.f:31:整数iargc,strlen1

bin2D2nc.f:32:external iargc,strlen1



bin2D2nc.f:44:i = iargc()


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

  gfortran -O3  - 固定行-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):未定义的引用'iargc_ '



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



make:** [bin2D2nc] Erro 1


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



我发现'iargc'是GNU Fotran 77向后兼容的例行程序,但是我不太了解它。

有人可能会提出一些建议来解决这个问题吗? 该问题与修复FORTRAN IV警告:参数的数目与intrinsinc过程不兼容,假设'external',但不同之处在于在另一个问题中存在外部函数并且与内在的相似性是无意的,但是



声明

  EXTERNAL IARGC 

表示 IARGC 是外部或这是FORTRAN 66中的一个内部函数,但在现代Fortran77及更高版本中,这意味着它只是一个外部函数。但是,您需要调用内部函数< a href =https://gcc.gnu.org/onlinedocs/gfortran/IAR GC.htmlrel =nofollow noreferrer> https://gcc.gnu.org/onlinedocs/gfortran/IARGC.html 。



您应该使用

  INTRINSIC IARGC 

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



最后一个注释 IARGC 本身不是标准的Fortran,在这里没关系。


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: integer iargc,strlen1

bin2D2nc.f:32: external iargc,strlen1

bin2D2nc.f:44: i=iargc()

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

I receive these messages:

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

collect2: error: ld returned 1 exit status

make: ** [bin2D2nc] Erro 1

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

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?

解决方案

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.

The statement

EXTERNAL IARGC

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.

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

You should use

 INTRINSIC 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.

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

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

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