ld 找不到 -lgfortran

its*_*rry 5 arch-linux make libraries cmake

我正在尝试使用 CMake 在 Arch Linux 上编译Knut(一个数学程序),但出现以下错误:

/usr/bin/ld: cannot find -lgfortran
/usr/bin/ld: cannot find -lquadmath
collect2: error: ld returned 1 exit status
make[2]: *** [cli/CMakeFiles/knut-cli.dir/build.make:101: cli/knut-cli] Error 1
make[1]: *** [CMakeFiles/Makefile2:498: cli/CMakeFiles/knut-cli.dir/all] Error 2
make: *** [Makefile:128: all] Error 2
Run Code Online (Sandbox Code Playgroud)

我相信gfortranquadmath都已安装,并且链接似乎也正确:

$ ls -al /usr/lib | grep "fortran"
lrwxrwxrwx   1 root root       20 Jun  3 23:11 libgfortran.so -> libgfortran.so.3.0.0
lrwxrwxrwx   1 root root       20 Jun  3 23:11 libgfortran.so.3 -> libgfortran.so.3.0.0
-rwxr-xr-x   1 root root  5858448 Jun  3 23:11 libgfortran.so.3.0.0
-rw-r--r--   1 root root      269 Jun  3 03:11 libgfortran.spec

$ ls -al /usr/lib | grep "libquadmath"
lrwxrwxrwx   1 root root       20 Jun  3 23:11 libquadmath.so -> libquadmath.so.0.0.0
lrwxrwxrwx   1 root root       20 Jun  3 23:11 libquadmath.so.0 -> libquadmath.so.0.0.0
-rwxr-xr-x   1 root root   958384 Jun  3 23:11 libquadmath.so.0.0.0
Run Code Online (Sandbox Code Playgroud)

在 .so 文件中也可以找到相同的 .so 文件/usr/lib64

我有 gfortran 6.1.1 版。我对 CMake 了解不多,所以我在 cmake 命令中尝试更改的唯一方法是添加-D CMAKE_PREFIX_PATH=/usr/lib,这没有帮助。

有什么建议我可以继续找到问题吗?

编辑1

我在cmake没有后续的情况下运行make,似乎满足了所有依赖项:

- The C compiler identification is GNU 6.1.1
-- The CXX compiler identification is GNU 6.1.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 6.1.1
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- The shell is found: /usr/bin/sh
-- The C++ runtime library is /usr/lib/gcc/x86_64-pc-linux-  gnu/6.1.1/../../../../lib/libstdc++.a
-- The FORTRAN runtime library is libgfortran.a, /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/libgcc.a and libquadmath.a
-- The DYNAMIC FORTRAN runtime library is /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/libgfortran.so
-- openBLAS was found as /usr/lib64/libopenblas.so.
-- Using system UMFPACK and AMD: /usr/lib64/libumfpack.so and /usr/lib64/libamd.so.
-- The includes are at /usr/include and /usr/include.
-- Using system LAPACK and ARPACK /usr/lib64/liblapack.so;/usr/lib64/libarpack.so.
-- The mxml library is /usr/lib64/libmxml.so.
-- The mxml include directory is /usr/include.
-- --> Qt5Core found.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mark/knut/knut/build
Run Code Online (Sandbox Code Playgroud)

当我随后运行make.

编辑2

我注意到我的 /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/ 不包含静态库libgfortran.alibquadmath.a. 我gcc-4.8.5在另一台计算机上有这些文件存在。从cmake输出来看,这两个库似乎没有找到,因为没有为它们提供路径。

现在我不确定这意味着什么,这是我的 gfortran 安装问题还是其他问题?

EDIT3 6 月 24 日

libgfortran 的问题似乎是 Arch 特有的。显然静态库通常不打包在 Arch 中。这就是为什么 Debian 中相同的 gcc-fortran 包包含文件 libgfortran.a 和 libquadmath.a 但在 Arch 中不包含的原因。我已将 PKGBUILD 中的选项更改options=('staticlibs')为包含用于下一次编译的静态库(使用abs)。然后我将生成的 libgfortran.a 和 libquadmath.a 文件复制到其中,libgfortran/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/的问题似乎解决了。

但是,我现在得到了 Knud Larsen 提到的 Qt5 错误。

Knu*_*sen 2


\n

https://github.com/rs1909/knut/tree/master/knut

\n
\n

/usr/bin/ld: 找不到 -lgfortran

\n

/usr/bin/ld: 找不到 -lquadmath

\n
\n

请阅读 knut/knut/knut.spec.cmake \xe2\x86\x92 Buildrequires: libgfortran-static .... 即 libgfortran。A

\n

-lquadmath 可能相同:libquadmath.a

\n

(我的 cmake 配置没有出现任何错误:Makefile 已创建。)

\n
\n

6 月 23 日编辑 1:上面似乎只是一个配置示例:Makefile 已创建。

\n

构建示例:PCLinuxOS 2016、CentOS 7、Fedora 24 因 Qt5 错误而失败。

\n
    \n
  • Debian 8 Jessie:没有问题,除了 cmake 在knut/knut/build/src/config.h. $make和 #make install都可以。\ngfortran、g++ 的版本是 4.9.2 。“libgfortran-4.9-dev”提供libgfortran.a、libquadmath.a
  • \n
\n
\n

编辑 2,6 月 23 日:使用 Ubuntu 16.04 进行构建...尝试更高版本的编译器 gcc-5.3.1 ...

\n
cd knut/knut/build/ && CC=gcc-5 CXX=g++-5 FC=gfortran-5 cmake .. && make && sudo make install\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • 没有问题 ....
  • \n
\n
\n

编辑 3:使用 gcc/g++/gfortran 版本6.1.1测试 knut \xe2\x86\x92 Debian 9 Stretch

\n
CC=gcc-6 CXX=g++-6 FC=gfortran-6 cmake .. && make ; # make install\n
Run Code Online (Sandbox Code Playgroud)\n
    \n
  • 也还可以。
  • \n
\n

编辑4:构建要求..#apt-get install g++ libopenblas-dev libqt5svg5-dev

\n

从以上所有我可以得出的结论是,所使用的Qt5必须适合。Qt5配置可能有差异?打补丁?...我没有发现 Qt5 文件位置有任何重要差异。

\n

\n