'How to link libs in CLion?

I'm using CLion as my IDE for C++ development and I'm trying to get Eigen included.

How do I do this? I've downloaded and unzipped Eigen and placed it in C:/ (Which I've read online is the path where CMake looks for libs when you use find_library())

In the CMakeLists.txt I've added

find_library(Eigen3 3.4 REQUIRED NO_MODULE)
add_executable(Lecture03 main.cpp)
target_link_libraries (Lecture03 Eigen3::Eigen)

But then it can't find Eigen, I get the following error when reloading my CMakeLists:

CMake Error at CMakeLists.txt:6 (find_library):
Could not find Eigen3 using the following names: 3.4

My question is, what did I do wrong? Did I place the Eigen folder in the wrong directory? Can I change where CMake looks for libs in CLion?



Solution 1:[1]

The solution ended up being to use

include_directories(C:/CPP_Libs/Eigen3)

in my CMakeLists.txt, and

#include <Eigen/Dense>

in whichever file needs it

Solution 2:[2]

Eigen (https://eigen.tuxfamily.org/index.php?title=Main_Page) is a template library. That means it is header only, there is nothing to link against.

For CMake that means you can use find_path to find the header file

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Therkelsen
Solution 2 arved