# RGB-D slam fails on catkin_make

Hi,

I am trying to make rgbdslam package and when I try catkin_make I get this error:

    In file included from /home/rover1/catkin_ws/build/rover_slam/rgbdslam/src/moc_graph_manager.cpp:9:0:
/home/rover1/catkin_ws/build/rover_slam/rgbdslam/src/../../../../src/rover_slam/rgbdslam/src/graph_manager.h:58:39: fatal error: g2o/core/sparse_optimizer.h: No such file or directory
compilation terminated.
rover_slam/rgbdslam/CMakeFiles/rgbdslam.dir/build.make:158: recipe for target 'rover_slam/rgbdslam/CMakeFiles/rgbdslam.dir/src/moc_graph_manager.cpp.o' failed
make[2]: *** [rover_slam/rgbdslam/CMakeFiles/rgbdslam.dir/src/moc_graph_manager.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed


We have installed the g2o package in a directory located in /home/rover1/rgbd_slam_dep/

I have exported export G2O_DIR=/home/rover1/rgbd_slam_dep/g2ofork/install And when we run env it appears in the environment list

It works when use the same directories specified, but when I create my own it fails

Would someone please be able to help me with this?

Thank you

edit retag close merge delete

Sort by » oldest newest most voted

Hello buckbuck,

I suggest you do the following... Change the CMakeLists.txt slightly so that it looks as follows:

find_package(G2O REQUIRED)
message("G2O_DIR " ${G2O_DIR})  Run catkin_make and find the added message. I suspect you did not get the wanted result and that your G2O_DIR is not pointing where you want. If that is the case, you can fix it by adding one line to your CMakeLists.txt. set(G2O_DIR$ENV{G2O_DIR})
find_package(G2O REQUIRED)


One caveat, however... You have to make sure that the environment variable exists in the terminal you are working in. Since you've checked it I guess that part is okay.

If you have any further questions, feel free to ask. :)

Update based on buckbuck's comment: To be able to understand why include directories are not the ones you expect, you have to know how find_package works. By setting the G2O_DIR you have explicitly said to CMake to try to find G2OConfig.cmake in the provided path. So, the find_package tries to find <package>Config.cmake file and inside it, <package>_INCLUDE_DIRS and <package>_LIBRARIES etc. are defined.

Therefore, I suspect that the path you have provided does not have G2OConfig.cmake file. Now, every package has a different build rules and not every package has the same configuration, but, if you have installed G2O to /home/rover1/rgbd_slam_dep/g2ofork, check in your build folder for Config.cmake file and if you have one, export the following:

export G2O_DIR=/home/rover1/rgbd_slam_dep/g2ofork/build


more

Hi dljubic,

I have found the problem, but unsure how to fix: --Found g2o headers in: /opt/ros/kinetic/include instead of: --Found g2o headers in /home/rover1/rgbd_slam_dep/g2ofork/install/include

How do I change where g2o headers are found?

Thank you

( 2018-09-16 22:11:40 -0600 )edit

Great job finding the problem! I have updated my answer since it was too long to put in a comment. Please let me know if it helps. If it does not help, please write how did you installed g2o.

p.s. Don't delete your comments, it is helpful for other users to see the whole discussion. :)

( 2018-09-17 04:06:44 -0600 )edit

There is a config.cmake but your answer did not work. Could the problem be from having rtab mapping in workspace which also uses g2o, thus causing the headers to point to the wrong location?

( 2018-09-18 22:37:43 -0600 )edit

I am not sure how that could cause the error. Can you please tell the value of the g2o_INCLUDE_DIRS and did you check if the file actually exists in g2o_INCLUDE_DIRS/g2o/core/sparse_optimizer.h. Maybe the #include in the code is incorrect.

( 2018-09-19 10:31:52 -0600 )edit

G2O_INCLUDE_DIRS /opt/ros/kinetic/include. Is there way to change where this points?

The sparse file does exist. When I edit it to point to the correct location of g2o it works, but then a different file fails. This can be fixed the same way but then another file fails.

( 2018-09-19 22:29:18 -0600 )edit

How did you installed g2o in /home/rover1/rgbd_slam_dep/? You cloned the g2o repository, created a build folder, changed the directory to build folder and did cmake .. followed by make or did you do make install? You should change where it points by setting G2O_DIR to your build location.

( 2018-09-20 09:20:47 -0600 )edit