Public bug reported: Hi,
I am trying to compile a C++ program with CMake 3.16.3 on Ubuntu 20.04 LTS, which ships OpenMPI 4.0.3. I realized that the mpic++ --showme:link flags forget to link `-lopen-pal`, which is part of the OpenMPI lib dir. -pthread -L/usr/lib/x86_64-linux-gnu/openmpi/lib -lmpi_cxx -lmpi Following that, a CMake CXX program compiled with clang++ that checks for `find_package(MPI REQUIRED)` will error out with: ``` -- Found MPI_C: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so (found version "3.1") -- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS) CMake Error at /usr/local/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message): -- Configuring incomplete, errors occurred! Could NOT find MPI (missing: MPI_CXX_FOUND CXX) (found version "3.1") ``` The reason for that is in the compile check ``` /opt/rocm/llvm/bin/clang++ -pthread CMakeFiles/cmTC_abf94.dir/test_mpi.cpp.o -o cmTC_abf94 -Wl,-rpath,/usr/lib/x86_64-linux-gnu/openmpi/lib /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_class_init_epoch [--no-allow-shlib-undefined] ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_list_item_t_class [--no-allow-shlib-undefined] ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_class_initialize [--no-allow-shlib-undefined] ld.lld: error: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so: undefined reference to opal_uses_threads [--no-allow-shlib-undefined] ``` where the linker refuses the missing lib and fails the check. The solution to this is to make sure that mpic++ --showme:link appends -lopen-pal as well. User-side work-around until fix is applied: export LDFLAGS="-lopen-pal" ** Affects: openmpi (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1941786 Title: OpenMPI 4.0.3 forgets to link open-pal To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/openmpi/+bug/1941786/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs