Skip to content

FindLAPACK: When building a shared library and MKL is selected automatically, the shared library becomes unusable

When building a shared library (func.so below) doing find_package(LAPACK) and MKL is selected automatically, LAPACK call from func.so will cause Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so.

I created an example here: https://gist.github.com/cielavenir/e2435395a093459fc6e51bd9bf33a6f8

This test.py will fail if both BLA_VENDOR in CMakeLists and sys.setdlopenflags in test.py are commented out. The situation is similar when func.so is loaded using dlopen in C. It is fine if func.so is linked statically though.

I suppose Intel10_64_dyn should be prioritized to Intel10_64lp.

Affected versions: 3.14 and later. Unfortunately func.so itself cannot be fixed before 3.17 because Intel10_64_dyn was introduced in 3.17.

3.13 is not affected if liblapack.so is linked to libmkl_rt because 3.13 searches (generic) liblapack first.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information