coin-or / Ipopt

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

libcoinmumps.so.3: cannot open shared object file #657

Closed dvogureckiy99 closed 1 year ago

dvogureckiy99 commented 1 year ago

Hi, I try compile code Ipopt with make -j4 and get error, but I installed it already:

After I changed command ./../configure --with-mumps-cflags=-I/usr/local/include/coin-or/mumps/ --with-mumps-lflags=-l:

/usr/bin/ld: /home/dvogureckiy99/git/Ipopt/build/src/.libs/libipopt.so: undefined reference to `dmumps_c'
collect2: error: ld returned 1 exit status

And I also tried A precompiled MUMPS library provided by a distributions package manager. Installed package libmumps-seq-dev and use the configure flags --with-mumps-cflags=-I/usr/include/mumps_seq --with-mumps-lflags=-ldmumps_seq.

./../configure --with-mumps-cflags=-I/usr/include/mumps_seq --with-mumps-lflags=-ldmumps_seq

And I have got the same error.

svigerske commented 1 year ago

In the first case, --with-mumps-lflags=-l is wrong. The argument --with-mumps-lflags expects all flags that are necessary to link against the Mumps library. I don't see what a single -l is supposed to achieve.
Easiest is usually to build Ipopt with the same --prefix as where you installed ThirdParty-Mumps before and let Ipopt's configure figure out the compiler and linker flags automatically.

I cannot really say why the second case fails with the same error. I see that this is something that worked for me once. Just check that the -ldumps_seq argument indeed made it into the linker flags (run make with V=1) and if that is the case, check whether libdumps_seq contains symbol dmumps_c, or whether there is another library that does so now.

dvogureckiy99 commented 1 year ago

Thank you for the answering me and your contribution.

I am nooby in all this instructions. Can you describe for me more deeply:

  1. For checking that the -ldumps_seq argument indeed made it into the linker flags I should run make V=1 -j4 ?
  2. And how to check whether  libdumps_seq contains symbol dmumps_c, or whether there is another library that does so now ?
svigerske commented 1 year ago
  1. Yes.
  2. I would use nm to list the symbols in the library.
dvogureckiy99 commented 1 year ago
  1. Yes.
  2. I would use nm to list the symbols in the library.

Sorry, for my misunderstanding. for 2 would be correct: nm -dmumps_c libdumps_seq

dvogureckiy99 commented 1 year ago

I tried let Ipopt's configure figure out the compiler and linker flags automatically and get the same error. I run make V=1 -j4 after ./../configure and get:

make[3]: Entering directory '/home/dvogureckiy99/git/Ipopt/build/src/Apps/AmplSolver'
/bin/bash ../../../libtool  --tag=CXX   --mode=link g++  -O2 -DNDEBUG  -version-number 3:14:12 -no-undefined  -o ipopt ampl_ipopt.o libipoptamplinterface.la ../../libipopt.la 
libtool: warning: '-version-info' is ignored for programs
libtool: link: g++ -O2 -DNDEBUG -o .libs/ipopt ampl_ipopt.o  ./.libs/libipoptamplinterface.so -L/usr/local/lib /home/dvogureckiy99/git/Ipopt/build/src/.libs/libipopt.so /usr/local/lib/libcoinasl.so -lm ../../.libs/libipopt.so -llapack -lblas -ldl
/usr/bin/ld: /home/dvogureckiy99/git/Ipopt/build/src/.libs/libipopt.so: undefined reference to `dmumps_c'
collect2: error: ld returned 1 exit status

And after ./../configure --prefix=/usr/local/ I get the same error.

dvogureckiy99 commented 1 year ago

I reinstall MUMPS and then ./../configure -> make -j4 without everything else and this worked.

dvogureckiy99 commented 1 year ago

but I encountered new error from make test:

 ---- 8< ---- Start of test program output ---- 8< ----
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/dvogureckiy99/git/Ipopt/build/src/.libs/libipopt.so.3.14.12: libcoinmumps.so.3: cannot open shared object file: No such file or directory
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2445)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2501)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2700)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2662)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.base/java.lang.System.loadLibrary(System.java:1873)
    at org.coinor.Ipopt.<init>(Ipopt.java:231)
    at HS071.<init>(HS071.java:37)
    at HS071.main(HS071.java:396)
 ---- 8< ----  End of test program output  ---- 8< ----
svigerske commented 1 year ago

You could add the path where you libcoinmumps.so.3 was installed to your LD_LIBRARY_PATH. Or just ignore it if you aren't going to use the Java interface.

dvogureckiy99 commented 1 year ago

Thank you, Okey, I found this file there /usr/local/lib , and I added it by adding to .bashrc this line export LD_LIBRARY_PATH=/usr/local/lib. make test went right.