User1234321232
User1234321232

Reputation: 547

C++ cmake throwing error

I am running sample programs in g2o graph library in linux using cmake. I am getting the following error. The file i am running has the following code

#include <Eigen/Core>

which is causing the error.

[  3%] Building CXX object data_fitting/CMakeFiles/circle_fit.dir/circle_fit.o g2o/trunk/g2o/examples/data_fitting/circle_fit.cpp:27:2    3: fatal error: Eigen/Core: No such file or directory
compilation terminated.
make[2]: *** [data_fitting/CMakeFiles/circle_fit.dir/circle_fit.o] Error 1
make[1]: *** [data_fitting/CMakeFiles/circle_fit.dir/all] Error 2

I am new to using cmake. Is this because of an error in the CMakeLists.txt file?

INCLUDE_DIRECTORIES(${CSPARSE_INCLUDE_DIR})

ADD_EXECUTABLE(circle_fit
  circle_fit.cpp
)
SET_TARGET_PROPERTIES(circle_fit PROPERTIES OUTPUT_NAME circle_fit${EXE_POSTFIX})
TARGET_LINK_LIBRARIES(circle_fit core solver_csparse)

ADD_EXECUTABLE(curve_fit
  curve_fit.cpp
)
SET_TARGET_PROPERTIES(curve_fit PROPERTIES OUTPUT_NAME curve_fit${EXE_POSTFIX})
TARGET_LINK_LIBRARIES(curve_fit core)

I am struggling with this for a day now. The tutorials available for cmake are also not helping much. How can I fix this error?

I tried adding include statement for /usr/include/eigen3 as the first answer suggested. But I cannot find any file named eigen3 in the /usr/include directory.

Is there any other possible path? How can I find it in linux?

Upvotes: 0

Views: 900

Answers (2)

shekhar
shekhar

Reputation: 1432

The readme says that you need to install libeigen3-dev (https://svn.openslam.org/data/svn/g2o/trunk/README)

If you are on Ubuntu user install it using apt-get or synaptic.

And for Windows :

"If you are compiling on Windows, please download Eigen3 and extract it. Within cmake-gui set the variable G2O_EIGEN3_INCLUDE to that directory"

Do read the 'readme' :)

Upvotes: 0

INait
INait

Reputation: 181

Try to include the eigen include folder in cmake.

INCLUDE_DIRECTORIES( /usr/include/eigen3 )

It worked for me on the same error.

Upvotes: 1

Related Questions