zhouyan/MCKL

Error when build the example code

Closed this issue · 6 comments

Hi Zhouyan,

I tried to build codes in the example folder but I got the following errors.

I already installed all the necessary software. I also installed mckl under the /opt/ folder. I guessed my cmake cannot detect mckl. Is there any hint I can try to solve this?

Thank you!

Best,

Yinsen

(base) yinsenm@yinsenm-DL:~/Desktop/example/build$ cmake .. -DCMAKE_BUILD_TYPE=Release
-- The CXX compiler identification is GNU 7.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- =================== Examples ==========================
-- algorithm
CMake Error at algorithm/CMakeLists.txt:34 (mckl_add_example):
  Unknown CMake command "mckl_add_example".


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.14)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "/home/yinsenm/Desktop/example/build/CMakeFiles/CMakeOutput.log".

Thank you for your prompt reply! I tried to use the CMake from the top of the source tree. After compiling, I couldn't find any executable files under the build folder. The building target is libmckl.a file.

Suppose that I would like to run the algorithm_pmcmc.cpp under MCKL/example/algorithm/src. What should I do to compile the code to executable using cmake? Can you also give an example about how to write a cmake file if the header files and lib file are installed under /opt/include/mckl and /opt/libs?

Thank you so much!!

I added the following lines to the CMakefiles in the root directory and changed cmake version to 3.1.

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Then I turn on the release mode and use the following commands from your tutorial in the readme file

cmake .. -DCMAKE_BUILD_TYPE=Release
make example

However, I got those errors this time. I am using ubuntu 18.04 , gcc 7.3.0 and cmake 3.14. Can you provide some hints? Thank you!

(base) yinsenm@yinsenm-DL:~/Desktop/MCKL/build$ make example
[  2%] Built target libmckl
Scanning dependencies of target utility_hdf5
[  2%] Building CXX object example/utility/CMakeFiles/utility_hdf5.dir/src/utility_hdf5.cpp.o
In file included from /home/yinsenm/Desktop/MCKL/include/mckl/internal/compiler.h:47:0,
                 from /home/yinsenm/Desktop/MCKL/include/mckl/internal/config.h:45,
                 from /home/yinsenm/Desktop/MCKL/include/mckl/random/rng.hpp:35,
                 from /home/yinsenm/Desktop/MCKL/example/utility/include/utility_hdf5.hpp:35,
                 from /home/yinsenm/Desktop/MCKL/example/utility/src/utility_hdf5.cpp:32:
/home/yinsenm/Desktop/MCKL/include/mckl/internal/compiler/gcc.h:151:2: error: #endif without #if
 #endif // MCKL_INTERNAL_COMPILER_GCC_H
  ^~~~~
example/utility/CMakeFiles/utility_hdf5.dir/build.make:62: recipe for target 'example/utility/CMakeFiles/utility_hdf5.dir/src/utility_hdf5.cpp.o' failed
make[3]: *** [example/utility/CMakeFiles/utility_hdf5.dir/src/utility_hdf5.cpp.o] Error 1
CMakeFiles/Makefile2:23888: recipe for target 'example/utility/CMakeFiles/utility_hdf5.dir/all' failed
make[2]: *** [example/utility/CMakeFiles/utility_hdf5.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/example.dir/rule' failed
make[1]: *** [CMakeFiles/example.dir/rule] Error 2
Makefile:164: recipe for target 'example' failed
make: *** [example] Error 2

Thanks for testing. It's a bug introduced while I was adding AVX512 optimization and did not properly test it against GCC. I have made hot fix release just now. Can you pull and test again?

Thank you for fixing that. Now I can compile the example folder successfully. Thank you for providing this awesome library!!