febiosoftware / FEBio

FEBio Suite Solver
https://febio.org/
MIT License
174 stars 65 forks source link

CMake Error: "Could not find MKL OMP library. Check MKL_OMP_LIB." #82

Closed lokitkhemka closed 5 months ago

lokitkhemka commented 5 months ago

I have openmp install and I have installed Intel MKL Library through the command sudo apt install intel-oneapi-mkl-devel.

However, I am getting the error "Could not find MKL OMP library. Check MKL_OMP_LIB.".

How to resolve this error? Thank you. I could not find anything in the Intel MKL docs.

Inside, Intel MKL install directory /opt/intel/oneapi/mkl/2024.0/bin there is an application called mkl_tool_link and when I run it, I get the following output, which might be relevant:

Compiler option(s):
 -m64  -I"/opt/intel/oneapi/mkl/2024.0/include"

Linking line:
 -Wl,--start-group /opt/intel/oneapi/mkl/2024.0/lib/libmkl_intel_lp64.a /opt/intel/oneapi/mkl/2024.0/lib/libmkl_gnu_thread.a /opt/intel/oneapi/mkl/2024.0/lib/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl

Environment variable(s):
There is no recommended environment variables

I am using Pop OS, a variant of Ubuntu, so solution for Ubuntu should work.

michaelrossherron commented 5 months ago

It looks like the CMake script is unable to automatically find MKL OMP library. However, you should be able to set that option manually. You need to locate the libiomp5.so library in your MKL installation. I used Intel's OneAPI installer rather than using apt to get it, and so it's possible that your directory structure is different than mine. My MKL OMP library is found here: /opt/intel/oneapi/compiler/latest/linux/compiler/lib/intel64_lin/libiomp5.so

If you run ccmake (sudo apt install cmake-curses-gui), then you'll get an in-terminal GUI that makes interacting with CMake a bit easier. If you push the t key, it will bring up the advanced options, and you should be able to find the MKL_OMP_LIB CMake variable. Just set that variable to the path of your libiomp5.so file, like so:

image

Give that a try, and let me know if you run into any more issues.

Michael Herron

lokitkhemka commented 5 months ago

Thank you for reply. That problem got resolved, but I am getting several undefined reference errors to functions like MMG3D_Get_scalarSol, __kmpc_critical_with_hint, GOMP_barrier. But I have linked to the lib folder of MMG.

Could they be related the following warning I got in CMake?

WARNING: Target "febioopt" requests linking to directory "/opt/intel/oneapi/compiler/latest/lib/".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "numcore" requests linking to directory "/opt/intel/oneapi/compiler/latest/lib/".  Targets may link only to libraries.  CMake is dropping the item.
WARNING: Target "feamr" requests linking to directory "/usr/local/lib".  Targets may link only to libraries.  CMake is dropping the item.

/usr/local/lib contain some of the functions listed above.

michaelrossherron commented 5 months ago

Apologies for the delay on the response here. Please make sure that the MKL_OMP_LIB CMake variable is pointing directly to the libiomp5.so library, and not to the folder that contains it. Similarly, make sure that the MMG_LIB CMake variable is pointing directly to the libmmg3.a library (or libmmg3.so) and not the directory that contains it.

lokitkhemka commented 5 months ago

Thanks, that resolved the issue and the project is now building and running fine.