coin-or / Ipopt

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

Compile error: Undefined MPI References During Ipopt Build with MUMPS and OpenMPI #791

Open ruturajsambhusvt opened 2 weeks ago

ruturajsambhusvt commented 2 weeks ago

Description

While building Ipopt with MUMPS and OpenMPI on Ubuntu 22.04, I'm encountering undefined references to various MPI functions during the make test phase. Despite ensuring that the correct MPI libraries and headers are installed and linked, the build fails with linker errors. Here's a detailed breakdown of the steps taken and the issues encountered.


Environment


Problem

During the make test phase of building Ipopt, the linker fails with the following errors:

/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Type_get_envelope'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `ompi_mpi_comm_null'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Abort'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Topo_test'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Group_excl'
...
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:515: hs071_cpp] Error 1
make: *** [Makefile:849: test] Error 2

Steps to Reproduce

  1. Installed MUMPS from source:

    • Configured MUMPS as follows:
      FC=gfortran CFLAGS=-fPIC FCFLAGS=-fPIC ./configure --prefix=/home/trec/WorkRaj/raisim_legged/MUMPS_5.7.3
    • Successfully built and installed MUMPS.
  2. Built and installed Ipopt:

    • Ran the following configuration command for Ipopt:

      ../configure --with-mumps \
      --with-mumps-libs="-L/home/trec/WorkRaj/raisim_legged/MUMPS_5.7.3/lib -ldmumps -lmumps_common -lpord -lscalapack-openmpi -llapack -lblas -lpthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi" \
      --with-mumps-cflags="-I/home/trec/WorkRaj/raisim_legged/MUMPS_5.7.3/include -I/usr/lib/x86_64-linux-gnu/openmpi/include" \
      --with-blas="-lblas" \
      --with-lapack="-llapack"
    • The build process completed without errors.

  3. Ran make test:

    • The build process failed during the test phase, with the linker throwing undefined references to various MPI symbols (e.g., MPI_Abort, MPI_Comm_dup, etc.).

Troubleshooting Steps Taken

  1. Verified MPI Installation:

    • Checked that the MPI headers exist at /usr/lib/x86_64-linux-gnu/openmpi/include, particularly mpi.h.
    • Verified that libmpi and libmpi_cxx are present via ldconfig.
  2. Tried Linking MPI Libraries Manually:

    • Attempted to add LIBS="-lmpi" to the make test command:
      make test LIBS="-lmpi"
    • The error persisted.
  3. Reconfigured Ipopt:

    • Adjusted the original configure command to explicitly point to OpenMPI libraries and headers:
      ../configure --with-mumps \
      --with-mumps-libs="-L/home/trec/WorkRaj/raisim_legged/MUMPS_5.7.3/lib -ldmumps -lmumps_common -lpord -lscalapack-openmpi -llapack -lblas -lpthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi" \
      --with-mumps-cflags="-I/home/trec/WorkRaj/raisim_legged/MUMPS_5.7.3/include -I/usr/lib/x86_64-linux-gnu/openmpi/include" \
      --with-blas="-lblas" \
      --with-lapack="-llapack"
    • The issue remained.

Logs

Output of ldconfig -p | grep mpi:

libmpi.so.40 (libc6,x86-64) => /lib/x86_64-linux-gnu/libmpi.so.40
libmpi.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libmpi.so
libmpi_cxx.so.40 (libc6,x86-64) => /lib/x86_64-linux-gnu/libmpi_cxx.so.40
libmpi_cxx.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libmpi_cxx.so
...

Full Error Log During make test:

/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Type_get_envelope'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `ompi_mpi_comm_null'
/usr/bin/ld: ../src/.libs/libipopt.so: undefined reference to `MPI_Abort'
...
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:515: hs071_cpp] Error 1
make: *** [Makefile:849: test] Error 2

Please find the terminal outputs of the respective commands.

make_test_output.txt make_output.txt configure_output.txt

svigerske commented 2 weeks ago

It should be --with-mumps-lflags. If that doesn't help, include the output of make and make test with argument V=1 to see compiler and linker calls.