coin-or / Couenne

Convex Over and Under Envelopes for Nonlinear Estimation
Eclipse Public License 1.0
72 stars 8 forks source link

build system fails to use libbonminampl #76

Closed haraldg closed 10 months ago

haraldg commented 10 months ago

At first, configure did detect that I have ASL, but failed to set the proper flags. This was easily solved with ./configure --with-asl --with-asl-cflags=-I/usr/local/include/coin-or/asl --with-asl-lflags=-lcoinasl (Sorry, I didn't keep the build logs for that.)

However then I got the following build error:

/bin/bash ../../libtool  --tag=CXX   --mode=link g++  -O2 -DNDEBUG  -no-undefined  -o couenne BonCouenne.o ../libCouenne.la 
libtool: link: g++ -O2 -DNDEBUG -o .libs/couenne BonCouenne.o  ../.libs/libCouenne.so -L/usr/local/lib /usr/local/lib/libbonmin.so /usr/local/lib/libipopt.so -ldmumps_seq -lCbcSolver -lCbc -lpthread -lrt -lCgl -lOsiClp -lClpSolver -lClp -lOsi -lCoinUtils -lbz2 -lz -llapack -lblas /usr/local/lib/libcoinasl.so -lm -ldl
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `Bonmin::AmplInterface::AmplInterface(Bonmin::AmplInterface const&)'
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `Bonmin::AmplInterface::AmplInterface()'
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `Bonmin::AmplTMINLP::AmplTMINLP(Ipopt::SmartPtr<Ipopt::Journalist const> const&, Ipopt::SmartPtr<Bonmin::RegisteredOptions>, Ipopt::SmartPtr<Ipopt::OptionsList>, char**&, Ipopt::AmplSuffixHandler*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `Bonmin::AmplInterface::~AmplInterface()'
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `Bonmin::AmplInterface::readAmplNlFile(char**&, Ipopt::SmartPtr<Bonmin::RegisteredOptions>, Ipopt::SmartPtr<Ipopt::OptionsList>, Ipopt::SmartPtr<Ipopt::Journalist>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*)'
/usr/bin/ld: ../.libs/libCouenne.so: undefined reference to `typeinfo for Bonmin::AmplInterface'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:427: couenne] Fehler 1

The problem appears to be, that libCouenne.so is not linked against libbonminampl:

$ ldd src/.libs/libCouenne.so
        linux-vdso.so.1 (0x00007fff9b3dc000)
        libbonmin.so.0 => /usr/local/lib/libbonmin.so.0 (0x00007f930a0d2000)
        libipopt.so.3 => /usr/local/lib/libipopt.so.3 (0x00007f9309e00000)
        libCbc.so.3 => /lib/x86_64-linux-gnu/libCbc.so.3 (0x00007f9309cd6000)
        libCgl.so.1 => /lib/x86_64-linux-gnu/libCgl.so.1 (0x00007f9309bcc000)
        libOsiClp.so.1 => /lib/x86_64-linux-gnu/libOsiClp.so.1 (0x00007f930a085000)
        libClp.so.1 => /lib/x86_64-linux-gnu/libClp.so.1 (0x00007f9309a43000)
        libOsi.so.1 => /lib/x86_64-linux-gnu/libOsi.so.1 (0x00007f930a02c000)
        libCoinUtils.so.3 => /lib/x86_64-linux-gnu/libCoinUtils.so.3 (0x00007f930991d000)
        liblapack.so.3 => /lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f9309000000)
        libcoinasl.so.2 => /usr/local/lib/libcoinasl.so.2 (0x00007f9309896000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9308c00000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f93097b7000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9308e1f000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9309797000)
        libblas.so.3 => /lib/x86_64-linux-gnu/libblas.so.3 (0x00007f9309755000)
        libdmumps_seq-5.5.so => /lib/x86_64-linux-gnu/libdmumps_seq-5.5.so (0x00007f9308800000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f930a384000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9309750000)
        libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007f930973d000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9308be1000)
        libatlas.so.3 => /lib/x86_64-linux-gnu/libatlas.so.3 (0x00007f9308400000)
        libgfortran.so.5 => /lib/x86_64-linux-gnu/libgfortran.so.5 (0x00007f9308000000)
        libmumps_common_seq-5.5.so => /lib/x86_64-linux-gnu/libmumps_common_seq-5.5.so (0x00007f9308b5e000)
        libquadmath.so.0 => /lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f9308b17000)
        libesmumps-7.0.so => /lib/x86_64-linux-gnu/libesmumps-7.0.so (0x00007f9309734000)
        libscotch-7.0.so => /lib/x86_64-linux-gnu/libscotch-7.0.so (0x00007f9308a86000)
        libscotcherr-7.0.so => /lib/x86_64-linux-gnu/libscotcherr-7.0.so (0x00007f9308e1a000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f9308a55000)
$

Even though the library is properly installed:

-rwxr-xr-x 1 harald staff    1212 11. Nov 23:22 /usr/local/lib/libbonminampl.la
lrwxrwxrwx 1 harald staff      22 11. Nov 23:22 /usr/local/lib/libbonminampl.so -> libbonminampl.so.0.0.0
lrwxrwxrwx 1 harald staff      22 11. Nov 23:22 /usr/local/lib/libbonminampl.so.0 -> libbonminampl.so.0.0.0
-rwxr-xr-x 1 harald staff  200272 11. Nov 23:22 /usr/local/lib/libbonminampl.so.0.0.0
-rwxr-xr-x 1 harald staff    1091 11. Nov 23:22 /usr/local/lib/libbonmin.la
lrwxrwxrwx 1 harald staff      18 11. Nov 23:22 /usr/local/lib/libbonmin.so -> libbonmin.so.0.0.0
lrwxrwxrwx 1 harald staff      18 11. Nov 23:22 /usr/local/lib/libbonmin.so.0 -> libbonmin.so.0.0.0
-rwxr-xr-x 1 harald staff 1306384 11. Nov 23:22 /usr/local/lib/libbonmin.so.0.0.0

In the end I managed to manually force it with: LDFLAGS=-lbonminampl ./configure --with-asl --with-asl-cflags=-I/usr/local/include/coin-or/asl --with-asl-lflags=-lcoinasl But since all I did was a standard configure - make - make install - sequence for ASL, ipopt, bonmin and couenne (which only failed at the last step) I think I shouldn't have to do this.

svigerske commented 10 months ago

I think I know why this happened when --with-asl-* were specified. Due to a bad choice of naming, when configuring Couenne, this should have been the flags to build against Bonmin's AMPL interface, and not only ASL. I hope this is fixed.