I have tried to compile one probabilistic model posted on github (https://github.com/gerowam/influence), but for the person who is not familiar with C language and compiling, it is really hard to know how to install relevant libraries and do compiling with "Makefile" on ubuntu 20.04.
The below is what I did for install required libraries according to short introduction to compile process on github webpage:
sudo apt-get update
sudo apt-get install git
sudo apt-get install make
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install libmkl-dev
sudo apt-get install libopenblas-dev
sudo apt-get install libhdf5-dev
sudo apt-get install liblapack-dev
sudo git clone http://www.github.com/gerowam/influence
And when I run "make," I've got the following:
swhan@swhan-VirtualBox:~/influence/dtm-dim-rdim/rdim$ make
g++ -w -Wunsafe-loop-optimizations -DSPARSE -DMKL -O3 -DMKL_ILP64 -DNDEBUG -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF -I ../lib/include -I ../lib -I ../lib/math -I ../gslwrap/include -I ../gslwrap/include/gslwrap -I ../local/include -I ../lib/util/gflags-1.1/src/gflags -I/include -I /include -I /include -m64 -fopenmp -frounding-math -msse4.2 -mfpmath=sse -march=native -fno-trapping-math -fno-signaling-nans -fno-signed-zeros -fgcse-after-reload -funsafe-loop-optimizations -fgcse-sm -fgcse-las -fipa-pta -funswitch-loops -c -o ss-lm.o ss-lm.c
In file included from ss-lm.h:29,
from ss-lm.c:15:
data.h:41:10: fatal error: mkl_lapacke.h: No such file or directory
41 | #include "mkl_lapacke.h"
| ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [<builtin>: ss-lm.o] Error 1
So I looked at Makefile, and it looks like this:
CFLAGS = -DSPARSE -DMKL -O3 -DMKL_ILP64 \
-DNDEBUG -DHAVE_INLINE -DGSL_RANGE_CHECK_OFF \
-I ${SPARSE_GSL_INC} -I ${LIB} -I ${LIB}/math -I ${GSLWRAP_LIB}/include \
-I ${GSLWRAP_LIB}/include/gslwrap -I ${LOCAL_DIR}/include \
-I ${LIB}/util/gflags-1.1/src/gflags -I${LOCAL}/include \
-I ${OPENBLAS_ROOT}/include \
-I ${MKLROOT}/include \
-m64 -fopenmp -frounding-math -msse4.2 -mfpmath=sse -march=native \
-fno-trapping-math -fno-signaling-nans -fno-signed-zeros \
-fgcse-after-reload -funsafe-loop-optimizations \
-fgcse-sm -fgcse-las -fipa-pta -funswitch-loops
#-I ../opt-local/openblas/include \
#-fprofile-use -fprofile-correction
#-fprofile-correction -fprofile-generate -fprofile-arcs -fprofile-values
But in Makefile, there do not exist macros for "MKLROOT" and "OPENBLAS_ROOT," but when I tried to set the macros for both, there is a problem. To be specific, it seems that MKL library is installed in the path of /usr/include/mkl but
-I ${MKLROOT}/include
the above made me confused about how to set the macros for MKL. In addition, if I set the following:
MKLROOT=/usr
...
-I ${MKLROOT}/include/mkl
another problem pops up. That is,
LDFLAGS = -Wl,-Map=ld_linkmap,-cref,-rpath -Wl,${LIB}/lib -L${LIB}/lib \
-L${LOCAL_DIR}/lib -L${LOCAL_DIR}/lib/stl \
-L../opt-local/openblas/lib -L/usr/lib/x86_64-linux-gnu/hdf5/serial \
-lhdf5 -lhdf5_hl -lgsl -lopenblas -lm \
-Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_gnu_thread -lgomp -ldl -lpthread
In this case, something related to "intel64" seems to be located at /usr/include/mkl/intel64 but then I have no idea how to proceed the above command. The following is the error message that I have got:
/usr/bin/ld: main.o: in function `main':
main.c:(.text.startup+0x156): undefined reference to `MKL_Set_Interface_Layer'
/usr/bin/ld: main.c:(.text.startup+0x15d): undefined reference to `MKL_Set_Threading_Layer'
collect2: error: ld returned 1 exit status
make: *** [Makefile:55: main] Error 1
As your MKL library is installed in /usr/include/mkl location, you can set MKLROOT environment variable as export MKLROOT=/usr/include/mkl
Another alternate is, to install oneAPI Base & HPC Toolkits from where you can get Intel MKL library package and initialize oneAPI environment which automatically
sets the MKLROOT. For more details regarding oneAPI Base Toolkit and oneAPI HPC Toolkit refer https://software.intel.com/content/www/us/en/develop/articles/installation-guide-for-intel-oneapi-toolkits.html
Refer to the below link regarding Intel oneMKL https://software.intel.com/content/www/us/en/develop/documentation/onemkl-linux-developer-guide/top/getting-started/setting-environment-variables/scripts-to-set-environment-variables.html