0

my cmake file

cmake_minimum_required (VERSION 2.8.11)
project (Transformation)

find_package(Eigen3 REQUIRED)
include_directories(EIGEN3_INCLUDE_DIR)

add_executable (Transformation main.cpp)

After I run make

/Users/.../main.cpp:2:9: fatal error: 'eigen3/Eigen/Core' file not found
#include<eigen3/Eigen/Core>
        ^~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/Transformation.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Transformation.dir/all] Error 2
make: *** [all] Error 2

OS: MacOS 11.2 cmake version: 3.9.16 make version: 3.81

qiuweikang
  • 47
  • 4
  • 1
    Similar question here: [https://stackoverflow.com/questions/12249140/find-package-eigen3-for-cmake](https://stackoverflow.com/questions/12249140/find-package-eigen3-for-cmake) – drescherjm May 07 '21 at 12:51
  • 1
    Just to make sure the path is correct, can you print it `message(STATUS "Eigen3 path: ${EIGEN3_INCLUDE_DIR}")` ? Otherwise, looks like dupe of question in another comment. – pptaszni May 07 '21 at 12:56
  • 1
    First, you're not expanding `${EIGEN3_INCLUDE_DIR}` like you should be. Second, you should not use `include_directories`. Use `target_include_directories` instead. – Alex Reinking May 07 '21 at 12:59
  • 1
    Also, you should not set the minimum CMake version below what you're actually using to test your build. CMake 2.8.11 is nearly 10 years old at this point. Upgrade! – Alex Reinking May 07 '21 at 13:00
  • Alex is correct. It should be `include_directories(${EIGEN3_INCLUDE_DIR})` instead of `include_directories(EIGEN3_INCLUDE_DIR)` – drescherjm May 07 '21 at 13:23
  • In your cpp file you should write `#include` (remove the leading `eigen3/`) – chtz May 07 '21 at 16:59
  • Tnanks for reply. – qiuweikang May 07 '21 at 17:10

0 Answers0