Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.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
Makefile 如何确定lgfortran指向的库 我试图用GNU make编译C++和FORTRAN的一个构建。在某些机器上,构建工作正常,而在其他机器上,我得到错误未定义的对“\u gfortran\u stop\u numeric\u f08”的引用。我认为fortran库存在一些问题,我正在努力解决这个问题_Makefile_Fortran_Gnu Make_Gfortran - Fatal编程技术网

Makefile 如何确定lgfortran指向的库 我试图用GNU make编译C++和FORTRAN的一个构建。在某些机器上,构建工作正常,而在其他机器上,我得到错误未定义的对“\u gfortran\u stop\u numeric\u f08”的引用。我认为fortran库存在一些问题,我正在努力解决这个问题

Makefile 如何确定lgfortran指向的库 我试图用GNU make编译C++和FORTRAN的一个构建。在某些机器上,构建工作正常,而在其他机器上,我得到错误未定义的对“\u gfortran\u stop\u numeric\u f08”的引用。我认为fortran库存在一些问题,我正在努力解决这个问题,makefile,fortran,gnu-make,gfortran,Makefile,Fortran,Gnu Make,Gfortran,在编译工作的机器上,gfortran版本是“GNU Fortran(SUSE Linux)4.8.5”。在/usr/lib64/中,我有以下库文件: libgfbgraph-0.2.so.0 libgfortran.so.3 libgfortran.so.4 libgfbgraph-0.2.so.0.0 libgfortran.so.3.0.0 libgfortran.so.4.0.0 在这些机器上,使用LDFlag-lgfortran编译工作正常。但是,使用-L/usr/lib64/libgf

在编译工作的机器上,gfortran版本是“GNU Fortran(SUSE Linux)4.8.5”。在
/usr/lib64/
中,我有以下库文件:

libgfbgraph-0.2.so.0 libgfortran.so.3 libgfortran.so.4 libgfbgraph-0.2.so.0.0 libgfortran.so.3.0.0 libgfortran.so.4.0.0

在这些机器上,使用LDFlag
-lgfortran
编译工作正常。但是,使用
-L/usr/lib64/libgfortran.so.4
-L/usr/lib64/libgfortran.so.3
进行编译时,会给出一个很长的错误列表

/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../../../../x86_64-suse-linux/bin/ld: io.f90:(.text+0x888d):未定义对“\u gfortran\u st\u write”的引用

因此,似乎使用标志
-lgfortran
我没有指向
-L/usr/lib64/libgfortran.so.4
-L/usr/lib64/libgfortran.so.3
。我怎样才能找出实际指向的图书馆呢

在其他机器上,即使使用标志
-lgfortran
,编译也无法工作。这就是我得到错误
未定义的引用“\u gfortran\u stop\u numeric\u f08”
。在这些机器上,gfortran版本是GNU Fortran(SUSE Linux)7.5.0”。在
/usr/lib64/
中,我有以下库文件:

libgfortran.so.4 libgfortran.so.4.0.0


关于如何解决这个问题有什么想法吗?

在提供
-lgfortran
时链接的库将始终是
libgfortran。因此
。最常见的是,这是指向实际文件的符号链接,稍后将由编译的二进制文件引用

现在,由于这是编译器提供的库,因此可以通过调用编译器来确定其位置,例如:

# Custom compiler
$ gfortran --version
GNU Fortran (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.

$ gfortran --print-file libgfortran.so
/proj/subcm/tools/Linux-x86_64/Santiago/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../lib64/libgfortran.so

$ readlink -f $(gfortran --print-file libgfortran.so)
/proj/subcm/tools/Linux-x86_64/Santiago/lib64/libgfortran.so.5.0.0


# Stock distribution compiler
$ /usr/bin/gfortran --version
GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.

$ /usr/bin/gfortran --print-file libgfortran.so
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgfortran.so

$ readlink -f $(/usr/bin/gfortran --print-file libgfortran.so)
/usr/lib64/libgfortran.so.3.0.0

你能告诉我们你正在使用的退出链接行吗?谷歌搜索显示gfortran_stop_numeric_f08在gfortran版本7.2左右消失了,因此代码中的某些内容是由早期版本编译的,因此未定义的引用使用了稍旧的7.5.0,但古老的4.8.5似乎找到了它。退出->精确在早期版本中t…看到了吗alsohttps://stackoverflow.com/questions/65164717/error-when-compile-umfpack-after-the-update-of-mac?noredirect=1#comment115220789_65164717 请注意结论:重新编译所有内容谢谢你的评论!问题似乎已经通过重新编译所有内容解决了。当然,我仍然不明白为什么它不是等价的当“/usr/lib64/libgfortran.so.3.0.0”是“readlink-f$(gfortran——打印文件libgfortran.so)的输出时,使用“-lgfortran”或“-L/usr/lib64/libgfortran.so.3.0.0”“@QuercusRobur,因为您混合了来自较旧和较新Gfortran的代码。libgfortran.so.3是旧版本,您不能仅将其链接到随gfortran最新版本一起提供的libfortran之外。谢谢您的回答!虽然它回答了我的直接问题,但它仍然让我感到困惑。在编译使用标志-lgfortran的计算机上,命令readlink-f$(gfortran——打印文件libgfortran.so)返回/usr/lib64/libgfortran.so.3.0.0。那么它是否应该等同于使用“-lgfortran”或tu使用“-L/usr/lib64/libgfortran.so.3.0.0”?前者有效,但后者无效。@QuercusRobur您看到问题下的注释了吗?@QuercusRobur,否。
-Lyyyy
用于将目录
yyy
添加到搜索路径
-lxxx
告诉编译器在库
libxxxx.a
(静态链接)或
libxxxx.so.#.#
(共享链接)中链接。@VladimirF感谢您的评论!是的,我通过重新编译所有内容来解决问题。@evets感谢您澄清这一点!我是(GNU)新手。