coin-or / Ipopt

COIN-OR Interior Point Optimizer IPOPT
https://coin-or.github.io/Ipopt
Other
1.36k stars 272 forks source link

coin-or-ipopt build error under Linux #726

Closed jimwang118 closed 3 months ago

jimwang118 commented 7 months ago

I am the maintainer of vcpkg. When I build coin-or-ipopt under the Linux platform, the following error occurs. I don't know much about make compilation. How can I fix this problem? ./vcpkg install coin-or-ipopt:x64-linux

configure: WARNING: lapack.pc and blas.pc present, but could not find dsyev when trying to link with LAPACK.
configure: error: Required package LAPACK not found.
svigerske commented 7 months ago

It seems that the pkg-config files that tell how to link against Lapack do not work. These files are part of the blas/lapack packages in your system. You may want to check config.log on details on why it failed. If you used some special linker flags, maybe you will have to overwrite the flags for linking against Blas+Lapack by using --with-lapack-lflags.

jimwang118 commented 7 months ago

It seems that the pkg-config files that tell how to link against Lapack do not work. These files are part of the blas/lapack packages in your system. You may want to check config.log on details on why it failed. If you used some special linker flags, maybe you will have to overwrite the flags for linking against Blas+Lapack by using --with-lapack-lflags.

In vcpkg we will use the internal lapack.pc file, but the configure file should search for lapack.pc in the system, so it cannot be found. But how to fix the search path of pkg-config in the makefile. I would also try compiling with the --with-lapack-lflags flag. This is the config.log with the error. Please help me analyze it. I really don’t know much about the make compilation process. Thank you very much.

config-x64-linux-dbg-config.log

svigerske commented 7 months ago

In config.log, start from the end and go up until you find the log for the test that failed. In this case, it is a bit more difficult, since you have first a warning and then an error and configure tries different naming schemes for a symbol, of which only one need to succeed. This one looks like the relevant one:

configure:23518: /usr/bin/cc -o conftest -fPIC -g  -L/mnt/vcpkg/installed/x64-linux/debug/lib conftest.c -L/mnt/vcpkg/installed/x64-linux/debug/lib/pkgconfig/../../lib -llapack -lopenblas  >&5
/usr/bin/ld: /mnt/vcpkg/installed/x64-linux/debug/lib/liblapack.a(iparmq.f.o): in function `iparmq_':
/mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/iparmq.f:271: undefined reference to `logf'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/iparmq.f:271: undefined reference to `lroundf'
/usr/bin/ld: /mnt/vcpkg/installed/x64-linux/debug/lib/liblapack.a(xerbla.f.o): in function `xerbla_':
/mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:87: undefined reference to `_gfortran_st_write'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:87: undefined reference to `_gfortran_string_len_trim'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:87: undefined reference to `_gfortran_transfer_character_write'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:87: undefined reference to `_gfortran_transfer_integer_write'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:87: undefined reference to `_gfortran_st_write_done'
/usr/bin/ld: /mnt/vcpkg/buildtrees/lapack-reference/src/v3.11.0-5e6de67bfb.clean/SRC/xerbla.f:89: undefined reference to `_gfortran_stop_string'

The blas.pc or lapack.pc said that to link against Lapack, one only needs -L/mnt/vcpkg/installed/x64-linux/debug/lib/pkgconfig/../../lib -llapack -lopenblas, but apparently these are static libraries build with gfortran and the Fortran runtime libraries (-lgfortran, maybe also -lquadmath) and the math library (-lm) are not mentioned as necessary linker flags in the .pc files.

Set environment variable PKG_CONFIG_PATH to overwrite where pkg-config is looking for .pc files.