gaoxiang12 / ORBSLAM2_with_pointcloud_map

830 stars 346 forks source link

libORB_SLAM2.so: undefined symbol: _ZN3g2o30OptimizationAlgorithmLevenbergC1EPNS_6SolverE #45

Open Jackyxtt opened 2 years ago

Jackyxtt commented 2 years ago

Compilation succeeded, but I met this issue when I run rgbd_tum. Following is the terminal information:

./Examples/RGB-D/rgbd_tum: symbol lookup error: /media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/ORB_SLAM2_modified/lib/libORB_SLAM2.so: undefined symbol: _ZN3g2o30OptimizationAlgorithmLevenbergC1EPNS_6SolverE

And in my CMakeLists.txt I made a few changes

# find_package( G2O REQUIRED )
set( G2O_INCLUDE_DIRS "/media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed/include" )
set( G2O_LIBRARIES "/media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed/lib")

include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/include
${EIGEN3_INCLUDE_DIR}
${Pangolin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
#------------newly added---------------------#
${G2O_INCLUDE_DIRS}
#------------newly added---------------------#
)

target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
${G2O_LIBRARIES}/libg2o_core.so ${G2O_LIBRARIES}/libg2o_types_slam3d.so 
${G2O_LIBRARIES}/libg2o_solver_csparse.so ${G2O_LIBRARIES}/libg2o_stuff.so 
${G2O_LIBRARIES}/libg2o_csparse_extension.so ${G2O_LIBRARIES}/libg2o_types_sim3.so 
${G2O_LIBRARIES}/libg2o_types_sba.so
${PCL_LIBRARIES}
)

I changed g2o_with_orbslam2 install path to /media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed

So I think I had include the right directories and link right libraries. But I still had this issue.

NeXT1995 commented 2 years ago

您好,你的邮件,杨沂林已经收到,我会尽快查收的,谢谢!

WOshihcy commented 2 years ago

同样的问题,求个解决办法pls

NeXT1995 commented 2 years ago

您好,你的邮件,杨沂林已经收到,我会尽快查收的,谢谢!

WOshihcy commented 2 years ago

Compilation succeeded, but I met this issue when I run rgbd_tum. Following is the terminal information:

./Examples/RGB-D/rgbd_tum: symbol lookup error: /media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/ORB_SLAM2_modified/lib/libORB_SLAM2.so: undefined symbol: _ZN3g2o30OptimizationAlgorithmLevenbergC1EPNS_6SolverE

And in my CMakeLists.txt I made a few changes

# find_package( G2O REQUIRED )
set( G2O_INCLUDE_DIRS "/media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed/include" )
set( G2O_LIBRARIES "/media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed/lib")

include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/include
${EIGEN3_INCLUDE_DIR}
${Pangolin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
#------------newly added---------------------#
${G2O_INCLUDE_DIRS}
#------------newly added---------------------#
)

target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so
${G2O_LIBRARIES}/libg2o_core.so ${G2O_LIBRARIES}/libg2o_types_slam3d.so 
${G2O_LIBRARIES}/libg2o_solver_csparse.so ${G2O_LIBRARIES}/libg2o_stuff.so 
${G2O_LIBRARIES}/libg2o_csparse_extension.so ${G2O_LIBRARIES}/libg2o_types_sim3.so 
${G2O_LIBRARIES}/libg2o_types_sba.so
${PCL_LIBRARIES}
)

I changed g2o_with_orbslam2 install path to /media/yxt/storage/SLAM_demo/ORBSLAM2_with_pointcloud_map/g2o_with_orbslam2/installed

So I think I had include the right directories and link right libraries. But I still had this issue.

It may be that the G2O in ROS conflicts with the G2O in engineering ,try sudo apt-get remove ros-noetic-libg2o,it works on me

dexiangwang commented 3 months ago

确实,通过apt-get remove ros-noetic-libg2o能解决库链接冲突的问题(注意ros版本)。但是我在想能不能把g2o文件夹放到ORB-SLAM2里的Thridparty文件夹里,然后修改一下CMakeLists.txt,就像ORB-SLAM2源码的配置那样,这样就直接在工程路径下链接g2o库就行,就不存在库冲突的问题了吧……

懒得弄了,大佬们或许可以试试