stella-cv / stella_vslam_ros

ROS package for stella_vslam
https://stella-cv.rtfd.io/en/latest/
Other
117 stars 77 forks source link

Error when building catkin_ws due to g2o #127

Closed AmineDh98 closed 1 year ago

AmineDh98 commented 1 year ago

Describe the bug

I am having a building error related to the g2o library when I try to run the stella_vslam_ros. First of all I followed the instructions and installed the stella_vslam and its working fine with the provided example videos and using socket viewer to visualize. Then I followed the instructions for stella_vslam_ros installations and when I wanted to build the catkin ws in the end it gave this Error: [ 66%] Built target cv_bridge_boost [ 77%] Linking CXX executable /home/dhem_am/catkin_ws/devel/lib/stella_vslam_ros/run_slam /usr/bin/ld: /usr/local/lib/libstella_vslam.so: undefined reference to g2o::OptimizableGraph::Edge::clone() const /usr/bin/ld: /usr/local/lib/libstella_vslam.so: undefined reference to g2o::OptimizableGraph::Vertex::clone() const collect2: error: ld returned 1 exit status make[2]: *** [stella_vslam_ros/src/CMakeFiles/run_slam.dir/build.make:381: /home/dhem_am/catkin_ws/devel/lib/stella_vslam_ros/run_slam] Error 1 make[1]: *** [CMakeFiles/Makefile2:3325: stella_vslam_ros/src/CMakeFiles/run_slam.dir/all] Error 2 make: *** [Makefile:146: all] Error 2 Invoking "make -j16 -l16" failed

I understood that the problem was occured when building the dependency with g2o so I rebuilt the g2o and stella_vslam packages following these commands:

-remove g2o using : sudo apt-get remove ros-noetic-libg2o -remove the build folder from g2o and rebuild it:

cd /tmp/g2o rm -rf build mkdir build && cd build cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_UNITTESTS=OFF \ -DG2O_USE_CHOLMOD=OFF \ -DG2O_USE_CSPARSE=ON \ -DG2O_USE_OPENGL=OFF \ -DG2O_USE_OPENMP=OFF \ -DG2O_BUILD_APPS=OFF \ -DG2O_BUILD_EXAMPLES=OFF \ -DG2O_BUILD_LINKED_APPS=OFF \ .. make -j4 && sudo make install

and the same for stella_vslam build folder: cd stella_slam rm -rf build mkdir build && cd build cmake \ -DUSE_STACK_TRACE_LOGGER=ON \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DUSE_PANGOLIN_VIEWER=OFF \ -DUSE_SOCKET_PUBLISHER=ON \ -DINSTALL_SOCKET_PUBLISHER=ON \ -DBUILD_TESTS=OFF \ -DBUILD_EXAMPLES=ON \ .. make -j4 && sudo make install install libg2o again using: sudo apt-get install ros-noetic-libg2o

And then run: cd catkin_ws catkin_make -DBUILD_WITH_MARCH_NATIVE=ON -DUSE_PANGOLIN_VIEWER=OFF -DUSE_SOCKET_PUBLISHER=ON -DUSE_STACK_TRACE_LOGGER=ON -DBOW_FRAMEWORK=DBoW2 -DUSE_OPENMP=OFF

After this, it returned success and catkin was able to find the dependencies.

Then I wanted to test stella_slam_ros by publishing a video to the topic "/camera/image_raw" and run: rosrun stella_vslam_ros run_slam -v ./orb_vocab.fbow -c ./equirectangular.yaml --map-db-out map.msg

However, I get this error: /home/dhem_am/catkin_ws/devel/lib/stella_vslam_ros/run_slam: symbol lookup error: /usr/local/lib/libstella_vslam.so: undefined symbol: _ZN3g2o7csparse7CSparseC1Ev To solve this I rebuilt the stella_vslam folder again (by removing build and rebuilding). After this it worked and I was able to visualize in the socket viewer the video that I am publishing and the vslam working.

The problem now is that if I build the catkin workspace again it will give the same error: /usr/bin/ld: /usr/local/lib/libstella_vslam.so: undefined reference to g2o::OptimizableGraph::Edge::clone() const /usr/bin/ld: /usr/local/lib/libstella_vslam.so: undefined reference to g2o::OptimizableGraph::Vertex::clone() const collect2: error: ld returned 1 exit status make[2]: *** [stella_vslam_ros/src/CMakeFiles/run_slam.dir/build.make:381: /home/dhem_am/catkin_ws/devel/lib/stella_vslam_ros/run_slam] Error 1 make[1]: *** [CMakeFiles/Makefile2:3325: stella_vslam_ros/src/CMakeFiles/run_slam.dir/all] Error 2 make: *** [Makefile:146: all] Error 2 Invoking "make -j16 -l16" failed So I need to do the previous steps again to build the catkin_ws and then again I will have the undefined symbol: _ZN3g2o7csparse7CSparseC1Ev ERROR.

Is there any way to solve this error ?


ymd-stella commented 1 year ago

Follow the Issue template.

Insufficient information.