- Download it from Eigen;
- Unzip it and create the
build
directory in the folder of the source folder; - Run cmake with
cmake -G "MinGW Makefiles" ../ -DCMAKE_INSTALL_PREFIX=/path/to/installation/folder
; - Run make with
make install
; - Locate the headers of
Eigen
and thecmake
configuration files located at the installation folder.
- Create a folder of
cmake
at the root directory of your source code; - Copy the configuration files of
Eigen
to the directory so-calledcmake
;./ ./main.cpp ./CMakeLists.txt ./cmake/ ./cmake/Eigen3Config.cmake ./cmake/Eigen3ConfigVersion.cmake ./cmake/Eigen3Targets.cmake ./cmake/UseEigen3.cmake
- Configure your
CMakeLists.txt
;cmake_minimum_required (VERSION 3.0) project (Name_Of_Your_Project) # important setting for accessing the eigen library list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") find_package(Eigen3 REQUIRED) include_directories(${EIGEN3_INCLUDE_DIR}) message("${CMAKE_MODULE_PATH}") message("${EIGEN3_INCLUDE_DIR}") add_executable (executable main.cpp) target_link_libraries(executable PUBLIC Eigen )
- Make a build directory namely
build
and change the working directory into that folder; - Run the
cmake
withcmake -G "MinGW Makefiles" ../ -DCMAKE_PREFIX_PATH=/path/to/installation/folder
; Note It is worthy of noting that theCMAKE_PREFIX_PATH
is the same as that of-DCMAKE_INSTALL_PREFIX
. - Run
make
withmake -j2
.