Error: cannot find -lmkl_intel_lp64 while compiling on Ubuntu 20.04

Ubuntu 20 is escalating positions as the heir of CentOS 7, and I started experiencing compatibility issues. I was compiling relion with the next options

cmake -DAMDFFTW=ON -DCUDA_ARCH=86 -DCUDA=ON -DCudaTexture=ON 
-DFORCE_OWN_FLTK=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc
-DMPI_C_COMPILER=/usr/bin/mpicc
-DMPI_C_LIBRARIES=/usr/lib/x86_64-linux-gnu/openmpi/lib/
-DMPI_C_INCLUDE_PATH=/usr/lib/x86_64-linux-gnu/openmpi/include/
-DCUDA_ARCH=61 -DCUDA=ON -DCudaTexture=ON -DMKLFFT=ON
-DFORCE_OWN_FLTK=ON -DGUI=ON
-DCMAKE_INSTALL_PREFIX=/XXX/relion_local/
-D CMAKE_BUILD_TYPE=Release ..

when I found this error

[ 59%] Linking CXX executable ../../bin/relion_tomo_tomo_ctf
/usr/bin/ld: cannot find -lmkl_intel_lp64
/usr/bin/ld: cannot find -lmkl_sequential
/usr/bin/ld: cannot find -lmkl_core
collect2: error: ld returned 1 exit status
make[2]: *** [src/apps/CMakeFiles/tomo_ctf.dir/build.make:102:
bin/relion_tomo_tomo_ctf] Error 1
make[1]: *** [CMakeFiles/Makefile2:352:
src/apps/CMakeFiles/tomo_ctf.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

I’m using the default package install locations, no modules or anything fancy. So it looks like some libraries are missing. Of course I try to find them with ldconfig -p | grep ‘mkl’ but they are obviously not there. Let’s install them:

# apt-get install libmkl*intel* libmkl*se* libmkl*core*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libmkl-intel-thread' for glob 'libmkl*intel*'
Note, selecting 'libmkl-blacs-intelmpi-ilp64' for glob 'libmkl*intel*'
Note, selecting 'libmkl-intel-ilp64' for glob 'libmkl*intel*'
Note, selecting 'libmkl-blacs-intelmpi-lp64'
for glob 'libmkl*intel*'
Note, selecting 'libmkl-intel-lp64' for glob 'libmkl*intel*'
Note, selecting 'libmkl-sequential' for glob 'libmkl*se*'
Note, selecting 'libmkl-core' for glob 'libmkl*core*'
Note, selecting 'libmkl-cdft-core' for glob 'libmkl*core*'
The following additional packages will be installed:
libmkl-def libmkl-locale libmkl-vml-def
The following NEW packages will be installed:
libmkl-blacs-intelmpi-ilp64 libmkl-blacs-intelmpi-lp64
libmkl-cdft-core libmkl-core libmkl-def
libmkl-intel-ilp64 libmkl-intel-lp64
libmkl-intel-thread libmkl-locale
libmkl-sequential libmkl-vml-def

0 upgraded, 11 newly installed, 0 to remove and 19 not upgraded.
Need to get 38,4 MB of archives.
After this operation, 204 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

You may need to run apt-get install mklibs in addition. Of course it depends on what you have been doing with your system so far, since this will call some python libraries also. After getting those packages, make and make install run without errors. Time to ask the user to test it…

Compiling SIDESPLITTER v1.2 on CentOS 7.X

Today’s working log is about SIDESPLITTER, a Local SNR Filter for both SIDES of SPLIT refinements. If you don’t know what that means, maybe you should study more 😉

The instructions on the github page here are a little meager but they were proven correct. On a few easy steps that I can perform as an user, first I clone the repo…

git clone https://github.com/StructuralBiology-ICLMedicine/SIDESPLITTER.git

Then I go into the newly created folder (SIDESPLITTER) and try

mkdir build && cd build
cmake ..

That produces an error in my case that reads

CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.1 or higher is required.  You are running version 2.8.12.2
-- Configuring incomplete, errors occurred!

Fortunately we have a module with a modern cmake. We load the module and try again. This time we have an error with the FFTW libraries (Fast Fourier Transform libraries). Like this:

CMake Error at CMakeLists.txt:14 (find_package):
  Could not find a package configuration file provided by "FFTW3" with any of
  the following names:

    FFTW3Config.cmake
    fftw3-config.cmake

  Add the installation prefix of "FFTW3" to CMAKE_PREFIX_PATH or set
  "FFTW3_DIR" to a directory containing one of the above files.  If "FFTW3"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

I have the libraries and I can link them, but instead let’s do as you read when you click on the github link. I quote the message just in case:

N.B. IF YOU EXPERIENCE FFTW LIBRARY ERRORS WITH THE CMAKE FILE, PLEASE
USE THE COMPILE.SH BASH SCRIPT PROVIDED – REQUIRES FFTW_DEVEL LIBRARIES

So I make the script executable (chmod 777 compile.sh) and run it. This will create a new binary sidesplitter that we can directly run to check the version and enjoy the ASCII art coming with it 🙂