I'm trying to compile Knut (a maths program) on Arch Linux with CMake and I'm getting the following error:
/usr/bin/ld: cannot find -lgfortran /usr/bin/ld: cannot find -lquadmath collect2: error: ld returned 1 exit status make: *** [cli/CMakeFiles/knut-cli.dir/build.make:101: cli/knut-cli] Error 1 make: *** [CMakeFiles/Makefile2:498: cli/CMakeFiles/knut-cli.dir/all] Error 2 make: *** [Makefile:128: all] Error 2
I believe both
quadmath are installed, and the links seem to be correct as well:
$ 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
The same .so files are also found in
I have gfortran version 6.1.1. I don't know much CMake so the only thing I tried to change in the cmake command is to add
-D CMAKE_PREFIX_PATH=/usr/lib, which didn't help.
Any suggestions how I could proceed to find the problem?
cmake without the subsequent
make and it seems all dependencies are met:
- 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
The aforementioned errors occur when I subsequently run
I've noticed that my /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/ does not contain the static libraries
libquadmath.a. I have
gcc-4.8.5 on another computer and there these files exist. From the
cmake output these are the two libraries that are not found it seems, since there is no path given for them.
Now I'm not sure what that means, whether that's a problem with my gfortran installation or something else?
EDIT3 June 24
The problem with libgfortran seems to be Arch specific. Apparently static libraries are usually not packaged in Arch. That's why the same gcc-fortran package in Debian contains files libgfortran.a and libquadmath.a but not in Arch. I've changed the options in PKGBUILD to
options=('staticlibs') to include the static libraries for the next compilation (using abs). Then I copied the generated libgfortran.a and libquadmath.a files into
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/ and the problem with libgfortran seems to be solved.
However, I'm getting now the Qt5 error mentioned by Knud Larsen.