zhangty019 / S3_DeformFDM

S^3-Slicer: A General Slicing Framework for Multi-Axis 3D Printing
BSD 3-Clause "New" or "Revised" License
87 stars 14 forks source link

Ubuntu 22.04 building fail: cmake & MKL #14

Open Spiritdude opened 1 year ago

Spiritdude commented 1 year ago

I used branch 'main-ubuntu', and I struggle with (One|Intel-)MKL and cmake.

My steps:

% sudo apt install intel-mkl libmkl-dev

and then

% mkdir build; cd build/
% cmake ..
CMake Error at CMakeLists.txt:18 (find_package):
  By not providing "FindMKL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "MKL", but
  CMake did not find one.

  Could not find a package configuration file provided by "MKL" with any of
  the following names:

    MKLConfig.cmake
    mkl-config.cmake

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

I found FindMKL.cmake at https://github.com/marian-nmt/marian-dev/blob/master/cmake/FindMKL.cmake and copied to /usr/local/share/cmake-3.24/Modules/, but didn't help either, as it's missing MKLROOT being set, which according some reports needs to be /usr but that didn't work either.

Can you describe the exact steps (like required packages) you got it compiled on Ubuntu 20.04 or 22.04?

My setup:

zhangty019 commented 1 year ago

Hello! My college has checked this problem, thanks @RyanTaoLiu

About the Intel-MKL, I used the tools from https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html?operatingsystem=linux&distributions=offline. And after installing, there will be a "setvars.sh" in the install dir. use source setvars.sh it will set some environments such as MKLROOT. (Just like the 4th line in CMakeLists.txt.)

Spiritdude commented 1 year ago

Thanks, I was able to move forward, but it still doesn't succeed.

Here the full installation steps:

sudo apt install -y qtcreator qtbase5-dev qt5-qmake cmake freeglut3-dev

Downloading installer shell-script file: https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html?operatingsystem=linux&distributions=offline

then

sudo sh <installer.sh>
source /opt/intel/oneapi/setvars.sh
mkdir build; cd build
cmake ..

but still fails with

-- Exectuted command:
/opt/intel/oneapi/mkl/2023.1.0/bin/intel64/mkl_link_tool;-opts;--mkl=11.3;--compiler=gnu_c;--os=lnx;--arch=intel64;--linking=dynamic
;--parallel=no;--interface=
-- Found MKL_LIBRARIES:
-Wl,--no-as-needed;mkl_intel_lp64;mkl_sequential;mkl_core;/usr/lib/x86_64-linux-gnu/libpthread.a;/usr/lib/x86_64-linux-gnu/libm.so;/
usr/lib/x86_64-linux-gnu/libdl.a
-- Found MKL_DEFINITIONS:

-- Found MKL_LIBRARY_DIR:
/opt/intel/oneapi/mkl/2023.1.0/lib/intel64;/opt/intel/oneapi/mkl/2023.1.0/../compiler/lib/intel64
-- Found MKL_INCLUDE_DIR:
/opt/intel/oneapi/mkl/2023.1.0/include
-- Found GLUT: /usr/lib/x86_64-linux-gnu/libglut.so
-- Configuring done
CMake Error at GLKLib/CMakeLists.txt:41 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>

  Target "MKL::MKL" not found.

CMake Error at ShapeLab/CMakeLists.txt:52 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>

  Target "MKL::MKL" not found.

CMake Error at GLKLib/CMakeLists.txt:41 (target_include_directories):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>

  Target "MKL::MKL" not found.

CMake Error at GLKLib/CMakeLists.txt:40 (target_compile_options):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>

  Target "MKL::MKL" not found.

CMake Error at ShapeLab/CMakeLists.txt:52 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_INCLUDE_DIRECTORIES>

  Target "MKL::MKL" not found.

CMake Error at ShapeLab/CMakeLists.txt:52 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS>

  Target "MKL::MKL" not found.

CMake Error at GLKLib/CMakeLists.txt:42 (target_link_libraries):
  Target "GLKLib" links to:

    MKL::MKL

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

CMake Error at ShapeLab/CMakeLists.txt:53 (target_link_libraries):
  Target "ShapeLab" links to:

    MKL::MKL

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

any package am I still missing? @RyanTaoLiu

RyanTaoLiu commented 1 year ago

Thanks, I set this referred by https://www.intel.com/content/www/us/en/docs/onemkl/developer-guide-macos/2023-1/cmake-config-for-onemkl.html. I am not sure any errors happen, if you could comment out those 3 lines about "target link and include", $<TARGET_PROPERTY:MKL::MKL,INTERFACE_COMPILE_OPTIONS> around GLKLib/CMakeLists.txt:40.

Spiritdude commented 1 year ago

I commented out ../GLKLib/CMakeLists.txt:40-42, and reran cmake .. which gave

CMake Error at ShapeLab/CMakeLists.txt:53 (target_link_libraries):
  Target "ShapeLab" links to:

    MKL::MKL

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

so I commented out ../ShapeLab/CMakeLists.txt:53 as well, after that:

cmake ..
cmake . --build --target ShapeLab -j 12

when I ran into another error:

[  1%] Automatic MOC for target GLKLib
[  3%] Automatic MOC for target QMeshLib
[  3%] Built target QMeshLib_autogen
[  3%] Built target GLKLib_autogen
Consolidate compiler generated dependencies of target GLKLib
Consolidate compiler generated dependencies of target QMeshLib
[ 46%] Built target QMeshLib
[ 70%] Built target GLKLib
[ 72%] Automatic MOC and UIC for target ShapeLab
[ 72%] Built target ShapeLab_autogen
Consolidate compiler generated dependencies of target ShapeLab
[ 74%] Linking CXX executable ShapeLab
/usr/bin/ld: CMakeFiles/ShapeLab.dir/MainWindow.cpp.o: in function `Eigen::internal::pardiso_run_selector<int>::run(void*, int, int, int, int, int, void*, int*, int*, int*, int, int*, int, void*, void*)':
MainWindow.cpp:(.text._ZN5Eigen8internal20pardiso_run_selectorIiE3runEPviiiiiS3_PiS4_S4_iS4_iS3_S3_[_ZN5Eigen8internal20pardiso_run_selectorIiE3runEPviiiiiS3_PiS4_S4_iS4_iS3_S3_]+0xaf): undefined reference to `pardiso'
collect2: error: ld returned 1 exit status
gmake[3]: *** [ShapeLab/CMakeFiles/ShapeLab.dir/build.make:368: ShapeLab/ShapeLab] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:243: ShapeLab/CMakeFiles/ShapeLab.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:250: ShapeLab/CMakeFiles/ShapeLab.dir/rule] Error 2
gmake: *** [Makefile:221: ShapeLab] Error 2

I installed l_onemkl_p_2023.1.0.46342_offline.sh for sake of reference.

RyanTaoLiu commented 1 year ago

Sorry for reply too late. In my point of view, /usr/bin/ld: CMakeFiles/ShapeLab.dir/MainWindow.cpp.o: in function Eigen::internal::pardiso_run_selector<int>::run(void*, int, int, int, int, int, void*, int*, int*, int*, int, int*, int, void*, void*)' means cmake cannot link the one mkl lib. If possible, would you mind checking the example of cmake-config-for-onemkl. If all config is right, I think shape up would build.

rvmn commented 11 months ago

just my 2cents: I always use Plocate to find the stuff and link them manually, that is usually what is needed on *nix OSs. Install plocate, run sudo updatedb to update the DB (do this every time you change stuff). Then I just searched MKL locate MKLConfig.cmake, found one (i installed onemkl using yay on arch) and used that to run cmake with MKL_DIR=<dir_path_to_MKLConfig.cmake> cmake .. Hope that helps. Btw, examples tend to crash still on my old laptop, and windows won't compile yet, if it's possible can you make and share a windows compiled version as release? EDIT: nvm, windows version compiles fine on exactly the versions specified (MS2019 with Qt5). thnk u.

beeekey commented 1 month ago

@Spiritdude how did you fix the MKL error? I'm stuck at the same point. Did you made a tutorial how do you installed it?