AntonBankevich / LJA

Other
110 stars 16 forks source link

Build issues and fixes #26

Open kcleal opened 2 years ago

kcleal commented 2 years ago

Hi @AntonBankevich Thanks for the nice tool.

I had some issues getting LJA to build using either Ubuntu21 (gcc 11.2) or CentOS (gcc 4.8). However I managed to find some fixes, so thought I would share for anyone else.

For the ubuntu system I got an error running make undefined reference to clock_gettime , which was fixed by adding -lrt to the make command. In CMakeLists.txt add -lrt to this line:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -lstdc++fs -ggdb3 ${OpenMP_CXX_FLAGS} -lrt" )

On the centos system, the build failed due to no c++17 support and no openmp on the system, so fixing this was a bit more involved:

First I made a conda env (or download a fresh version of miniconda)

conda create --name lja_env conda activate lja_env

Then install the following libs

conda install -c conda-forge compilers conda install -c ehmoussi cmake conda install -c ehmoussi make conda install -c conda-forge llvm-openmp conda install -c conda-forge gdb

Change the following lines in CMakeLists.txt, making sure to change env to the full env path and setting -lrt:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ienv/include -std=c++17 -lstdc++fs -ggdb3 ${OpenMP_CXX_FLAGS} -lrt" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ienv/include ${OpenMP_C_FLAGS}")

Next run cmake with flags for openmp support. MLIB here refers to the lib directory in your conda environent, which will be something like /home/user1/miniconda3/lib. Not sure if all these options are necessary:

cmake -DOpenMP_C_FLAGS=-fopenmp=lomp -DOpenMP_CXX_FLAGS=-fopenmp=lomp -DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" -DOpenMP_libomp_LIBRARY="${MLIB}/libomp.so" -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp ${MLIB}/libomp.so -I${MLIB}" -DOpenMP_CXX_LIB_NAMES="libomp" -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp ${MLIB}/libomp.so -I${MLIB}" CMakeLists.txt

Next run:

make bin/run_tests

PengJia6 commented 2 years ago

@kcleal Thx! I met same problem. That's very helpful!