I'm trying to use Eigen3 to calculate inversion of a matrix, but during compile it throws an error
my Eigen3 vision is 3.3.9, run under Ubuntu 18.04
CMakeFiles/test.dir/test.cpp.o:in function‘main’:
test.cpp:(.text+0x2a7):undefined reference of‘Eigen::MatrixBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> >::inverse() const’
(this might not be the exact error info because I translate it from Chinese, but I can ensure it says "undefined reference")
and this is my code
#include<Eigen/Core>
#include<iostream>
using namespace std;
using namespace Eigen;
int main()
{
Matrix4f M;
M<< 0.932322, 0.125848, -0.85106, -0.313612, -1.50979, -0.691102,
0.125848, 0.663803, -0.555993, 0.117918, -0.645694, -0.625737,
-0.85106, -0.555993, 1.26442, 0.39079;
cout << "Inverse= " << M.inverse() << endl;
}
and my CMakeLists.txt
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(test)
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})
add_executable(test test.cpp)
I noticed similar question but that one is caused by cuda. I do have cuda installed on my computer but I'm not using it.
Thank you for reading this and helping me.