opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
791 stars 317 forks source link

Error linking ipopt libraries to tropter during build #3952

Open saehuber opened 6 days ago

saehuber commented 6 days ago

I'm trying to build Opensim 4.5.1 from source on Linux and running into issues. It looks like the copy of libtropter in my build folder is not able to find the ipopt and colpack libraries during the test_derivatives linking step below, though in the configure step, CMake does appear to find these libraries successfully. Maybe something is missing from the cmake setup for this step?

I have the following options set for my configuration

configopts = "-DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_PYTHON_WRAPPING=ON -DBUILD_JAVA_WRAPPING=ON -DWITH_BTK=ON \
-DOPENSIM_WITH_CASADI=ON -DOPENSIM_WITH_TROPTER=ON -Ddocopt_DIR=%(builddir)s/opensim_dependencies_install/docopt/lib64/cmake/docopt/ \
-DOPENSIM_DEPENDENCIES_DIR=%(builddir)s/opensim_dependencies_install \
-DCMAKE_SKIP_INSTALL_RPATH=OFF \
-DTROPTER_COPY_DEPENDENCIES=ON \
-DTROPTER_WITH_OPENMP=ON"

I'm using intel compilers and CMake 3.27.7

[ 14%] Linking CXX executable ../../../test_derivatives
....
icpx: warning: argument unused during compilation: '-ftz' [-Wunused-command-line-argument]
/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/binutils-bin/2.41/ld: warning: libipopt.so.3, needed by ../../../libtropter.so, not found (try using -rpath or -rpath-link)
/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/binutils-bin/2.41/ld: warning: libColPack.so.0, needed by /tmp/shuber/avx2/opensim/4.5.1/iofbf-2023a/opensim_dependencies_install/adol-c/lib64/libadolc.so, not found (try using -rpath or -rpath-link)
/cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/x86_64-pc-linux-gnu/binutils-bin/2.41/ld: ../../../libtropter.so: undefined reference to `IpoptApplicationFactory'
icpx: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Vendors/tropter/tests/CMakeFiles/test_derivatives.dir/build.make:104: test_derivatives] Error 1
nickbianco commented 5 days ago

@saehuber, thanks for reporting. Before we start looking for CMake bugs, could you confirm that the opensim_dependencies_install folder contains ipopt and colpack folders. If not, you probably need to set OPENSIM_WITH_TROPTER=ON and OPENSIM_WITH_CASADI=ON when building the dependencies CMake project.

saehuber commented 3 days ago

Thanks! Yes, ipopt and colpack both built correctly during the dependencies build and are in the opensim_dependencies_install folder.

nickbianco commented 2 days ago

Okay good, thanks for checking that. A couple more questions/commnets:

It is likely that the choice of distro and compiler are breaking the rpaths. If switching to Ubuntu or a different compiler is not an option for you, then @aymanhab or I could try to help sort out the rpath issue.

aymanhab commented 2 days ago

I'd also add that we use patchelf to modify rpath on linux/ ubuntu.

saehuber commented 2 days ago

Thanks, both. I've switched to gcc 12.3but it's still failing with the same error; unfortunately switching distros is not an option. I'm building from the 4.5.1 tag. Let me know if there's more output that would be helpful in figuring out the rpaths issue.

nickbianco commented 17 hours ago

I think the next things to try are:

  1. Verify that libraries needed by tropter (libipopt.so.3 and libColPack.so.0) exist in the dependencies installation directory. And if so...
  2. Try running -rpath or -rpath-link, like the error messages suggest.
aymanhab commented 17 hours ago

Due to the long list of dependencies, are you sure you want to build tropter or moco altogether for your workflow?