ORB_SLAM2 icon indicating copy to clipboard operation
ORB_SLAM2 copied to clipboard

Undefined reference to symbol '_ZN5boost6system15system_categoryEv'

Open AldrichCabrera opened this issue 7 years ago • 30 comments

Hello, I have a problem with the new ROS libopencv_calib3d3.so.3.3.1 just now after an Ubuntu update, I solved this problem deleting the build and devel folder to then compile the new libs but now the problem is other when I try to compile the ORB_SLAM2 with ROS obtaining the next problems:

aldrich98@raldrich98:~/catkin_ws/src/ORB_SLAM2$ ./build_ros.sh Building ROS nodes mkdir: cannot create directory ‘build’: File exists [rosbuild] Building package ORB_SLAM2 [rosbuild] using multiarch 'x86_64-linux-gnu' for finding Boost

[ 0%] Built target rospack_genmsg_libexe [ 0%] Built target rosbuild_precompile [ 12%] Built target Mono_INEGI [ 18%] Linking CXX executable ../Stereo [ 25%] Linking CXX executable ../RGBD [ 37%] Built target Mono_Extractor [ 50%] Built target Mono [ 56%] Linking CXX executable ../RGBD_fake [ 75%] Built target MonoAR /usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/RGBD.dir/build.make:217: recipe for target '../RGBD' failed make[2]: *** [../RGBD] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/Stereo.dir/build.make:217: recipe for target '../Stereo' failed make[2]: *** [../Stereo] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2 /usr/bin/ld: CMakeFiles/RGBD_fake.dir/src/ros_rgbd_fake.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/RGBD_fake.dir/build.make:243: recipe for target '../RGBD_fake' failed make[2]: *** [../RGBD_fake] Error 1 CMakeFiles/Makefile2:733: recipe for target 'CMakeFiles/RGBD_fake.dir/all' failed make[1]: *** [CMakeFiles/RGBD_fake.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

AldrichCabrera avatar Dec 27 '17 22:12 AldrichCabrera

it's because the program can't find libboost_system.so and libboost_filesystem.so . Copy the two libs to ORB_SLAM2/lib , and then modify the CMakeLists.txt

     set(LIBS 
${OpenCV_LIBS} 
${EIGEN3_LIBS} 
${Pangolin_LIBRARIES} 
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so 
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so 
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so 
++
${PROJECT_SOURCE_DIR}/../../../lib/libboost_filesystem.so 
${PROJECT_SOURCE_DIR}/../../../lib/libboost_system.so

and you can use locate boost_system boost_filesystem to find it

jingresume avatar Dec 28 '17 12:12 jingresume

I solved this problem adding this:

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

-lboost_system

AldrichCabrera avatar Dec 28 '17 19:12 AldrichCabrera

Did you add all the above to the end of the CMakeLists.txt? Did you also do anything else? I am getting the exact same output as you got, but I have not been able to fix this yet. Thank you!

teundeplanque avatar Jan 08 '18 21:01 teundeplanque

I only put -lboost_system inside set(LIBS...) Could show us the error? And your CMakeList.txt

AldrichCabrera avatar Jan 09 '18 02:01 AldrichCabrera

I get the following error:

teun@teun-VirtualBox:~/ORB_SLAM2$ ./build_ros.sh Building ROS nodes mkdir: cannot create directory ‘build’: File exists [rosbuild] Building package ORB_SLAM2 [rosbuild] using multiarch 'x86_64-linux-gnu' for finding Boost -- Using CATKIN_DEVEL_PREFIX: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/kinetic -- This workspace overlays: /opt/ros/kinetic -- Using PYTHON_EXECUTABLE: /usr/bin/python -- Using Debian Python package layout -- Using empy: /usr/bin/empy -- Using CATKIN_ENABLE_TESTING: ON -- Skip enable_testing() for dry packages -- Using CATKIN_TEST_RESULTS_DIR: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/test_results -- Found gtest sources under '/usr/src/gtest': gtests will be built -- Using Python nosetests: /usr/bin/nosetests-2.7 -- catkin 0.7.8 -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy [rosbuild] Including /opt/ros/kinetic/share/roslisp/rosbuild/roslisp.cmake [rosbuild] Including /opt/ros/kinetic/share/roscpp/rosbuild/roscpp.cmake [rosbuild] Including /opt/ros/kinetic/share/rospy/rosbuild/rospy.cmake Build type: Release -- Using flag -std=c++11. -- Configuring done -- Generating done -- Build files have been written to: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build [ 0%] Built target rospack_genmsg_libexe [ 0%] Built target rosbuild_precompile [ 11%] Linking CXX executable ../RGBD [ 22%] Linking CXX executable ../Stereo [ 44%] Built target Mono [ 77%] Built target MonoAR /usr/bin/ld: CMakeFiles/RGBD.dir/src/ros_rgbd.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/RGBD.dir/build.make:216: recipe for target '../RGBD' failed make[2]: *** [../RGBD] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... /usr/bin/ld: CMakeFiles/Stereo.dir/src/ros_stereo.cc.o: undefined reference to symbol '_ZN5boost6system15system_categoryEv' /usr/lib/x86_64-linux-gnu/libboost_system.so: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status CMakeFiles/Stereo.dir/build.make:216: recipe for target '../Stereo' failed make[2]: *** [../Stereo] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

I added -lboost_system to CMakeList.txt like this:

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/lib/libORB_SLAM2.so -lboost_system )

This is my whole CMakeList.txt:

cmake_minimum_required(VERSION 2.8) project(ORB_SLAM2)

IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) ENDIF()

MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions(-DCOMPILEDWITHC11) message(STATUS "Using flag -std=c++11.") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_definitions(-DCOMPILEDWITHC0X) message(STATUS "Using flag -std=c++0x.") else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3.0 QUIET) if(NOT OpenCV_FOUND) find_package(OpenCV 2.4.3 QUIET) if(NOT OpenCV_FOUND) message(FATAL_ERROR "OpenCV > 2.4.3 not found.") endif() endif()

find_package(Eigen3 3.1.0 REQUIRED) find_package(Pangolin REQUIRED)

include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${EIGEN3_INCLUDE_DIR} ${Pangolin_INCLUDE_DIRS} )

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

add_library(${PROJECT_NAME} SHARED src/System.cc src/Tracking.cc src/LocalMapping.cc src/LoopClosing.cc src/ORBextractor.cc src/ORBmatcher.cc src/FrameDrawer.cc src/Converter.cc src/MapPoint.cc src/KeyFrame.cc src/Map.cc src/MapDrawer.cc src/Optimizer.cc src/PnPsolver.cc src/Frame.cc src/KeyFrameDatabase.cc src/Sim3Solver.cc src/Initializer.cc src/Viewer.cc )

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/lib/libORB_SLAM2.so -lboost_system )

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D)

add_executable(rgbd_tum Examples/RGB-D/rgbd_tum.cc) target_link_libraries(rgbd_tum ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Stereo)

add_executable(stereo_kitti Examples/Stereo/stereo_kitti.cc) target_link_libraries(stereo_kitti ${PROJECT_NAME})

add_executable(stereo_euroc Examples/Stereo/stereo_euroc.cc) target_link_libraries(stereo_euroc ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular)

add_executable(mono_tum Examples/Monocular/mono_tum.cc) target_link_libraries(mono_tum ${PROJECT_NAME})

add_executable(mono_kitti Examples/Monocular/mono_kitti.cc) target_link_libraries(mono_kitti ${PROJECT_NAME})

add_executable(mono_euroc Examples/Monocular/mono_euroc.cc) target_link_libraries(mono_euroc ${PROJECT_NAME})

And added this to the end of the ~/.bashrc file source /opt/ros/kinetic/setup.bash export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/teun/ORB_SLAM2/Examples/ROS

teundeplanque avatar Jan 09 '18 09:01 teundeplanque

Ok. In your first CmakeList.txt remove -lboost_system:

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/lib/libORB_SLAM2.so )

In your second CmakeList should put this flag in these parts:

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib -lboost_system )

Remove -lboost_system here:

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/lib/libORB_SLAM2.so )

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D -lboost_system )

add_executable(rgbd_tum Examples/RGB-D/rgbd_tum.cc) target_link_libraries(rgbd_tum ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Stereo -lboost_system )

add_executable(stereo_kitti Examples/Stereo/stereo_kitti.cc) target_link_libraries(stereo_kitti ${PROJECT_NAME})

add_executable(stereo_euroc Examples/Stereo/stereo_euroc.cc) target_link_libraries(stereo_euroc ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular -lboost_system)

add_executable(mono_tum Examples/Monocular/mono_tum.cc) target_link_libraries(mono_tum ${PROJECT_NAME})

add_executable(mono_kitti Examples/Monocular/mono_kitti.cc) target_link_libraries(mono_kitti ${PROJECT_NAME})

add_executable(mono_euroc Examples/Monocular/mono_euroc.cc) target_link_libraries(mono_euroc ${PROJECT_NAME})

I hope it works.

AldrichCabrera avatar Jan 09 '18 17:01 AldrichCabrera

I added the -lboost_system flags but continue to get the same error after changing my CMakeLists.txt file. This is the updated CMakeLists.txt file (-lboost_system in bold):

cmake_minimum_required(VERSION 2.8) project(ORB_SLAM2)

IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) ENDIF()

MESSAGE("Build type: " ${CMAKE_BUILD_TYPE})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions(-DCOMPILEDWITHC11) message(STATUS "Using flag -std=c++11.") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_definitions(-DCOMPILEDWITHC0X) message(STATUS "Using flag -std=c++0x.") else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

find_package(OpenCV 3.0 QUIET) if(NOT OpenCV_FOUND) find_package(OpenCV 2.4.3 QUIET) if(NOT OpenCV_FOUND) message(FATAL_ERROR "OpenCV > 2.4.3 not found.") endif() endif()

find_package(Eigen3 3.1.0 REQUIRED) find_package(Pangolin REQUIRED)

include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include ${EIGEN3_INCLUDE_DIR} ${Pangolin_INCLUDE_DIRS} )

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib -lboost_system )

add_library(${PROJECT_NAME} SHARED src/System.cc src/Tracking.cc src/LocalMapping.cc src/LoopClosing.cc src/ORBextractor.cc src/ORBmatcher.cc src/FrameDrawer.cc src/Converter.cc src/MapPoint.cc src/KeyFrame.cc src/Map.cc src/MapDrawer.cc src/Optimizer.cc src/PnPsolver.cc src/Frame.cc src/KeyFrameDatabase.cc src/Sim3Solver.cc src/Initializer.cc src/Viewer.cc )

target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/lib/libORB_SLAM2.so )

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/RGB-D -lboost_system )

add_executable(rgbd_tum Examples/RGB-D/rgbd_tum.cc) target_link_libraries(rgbd_tum ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Stereo -lboost_system )

add_executable(stereo_kitti Examples/Stereo/stereo_kitti.cc) target_link_libraries(stereo_kitti ${PROJECT_NAME})

add_executable(stereo_euroc Examples/Stereo/stereo_euroc.cc) target_link_libraries(stereo_euroc ${PROJECT_NAME})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/Examples/Monocular -lboost_system )

add_executable(mono_tum Examples/Monocular/mono_tum.cc) target_link_libraries(mono_tum ${PROJECT_NAME})

add_executable(mono_kitti Examples/Monocular/mono_kitti.cc) target_link_libraries(mono_kitti ${PROJECT_NAME})

add_executable(mono_euroc Examples/Monocular/mono_euroc.cc) target_link_libraries(mono_euroc ${PROJECT_NAME})

teundeplanque avatar Jan 09 '18 21:01 teundeplanque

Ok, I got confused. Remove all the flags in that CMakeList. I see that this CMakeList is the principal, you should do the changes in the ROS CMakeList. I think that is here: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeList.txt

It should have this:

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

AldrichCabrera avatar Jan 10 '18 22:01 AldrichCabrera

It is working now. :) Thank you very much for the support! I really appreciate your help AldrichCabrera.

teundeplanque avatar Jan 11 '18 09:01 teundeplanque

@AldrichCabrera thank you

ujur007 avatar Jul 04 '18 17:07 ujur007

@AldrichCabrera Thank you!

LuoJie996 avatar Aug 02 '18 02:08 LuoJie996

@AldrichCabrera Thank you

MarcusFutterlieb avatar Aug 02 '18 15:08 MarcusFutterlieb

@AldrichCabrera Thank you

leticiahelenasp avatar Aug 23 '18 00:08 leticiahelenasp

@AldrichCabrera I have followed your instructions, but it doesn't work for me.

TengFeiHan0 avatar Aug 29 '18 02:08 TengFeiHan0

@AldrichCabrera Thank you!!

cmdraghici avatar Sep 03 '18 18:09 cmdraghici

Thanks you !!

ShettyHarapanahalli avatar Sep 21 '18 08:09 ShettyHarapanahalli

@AldrichCabrera Thank you!

cobnst avatar Oct 28 '18 14:10 cobnst

it's because the program can't find libboost_system.so and libboost_filesystem.so . Copy the two libs to ORB_SLAM2/lib , and then modify the CMakeLists.txt

     set(LIBS 
${OpenCV_LIBS} 
${EIGEN3_LIBS} 
${Pangolin_LIBRARIES} 
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so 
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so 
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so 
++
${PROJECT_SOURCE_DIR}/../../../lib/libboost_filesystem.so 
${PROJECT_SOURCE_DIR}/../../../lib/libboost_system.so

and you can use locate boost_system boost_filesystem to find it

I Tried this but face some more error

make[2]: *** No rule to make target '../../../../lib/libboost_filesystem.so', needed by '../Mono'. Stop. make[2]: *** No rule to make target '../../../../lib/libboost_filesystem.so', needed by '../Stereo'. Stop. CMakeFiles/Makefile2:718: recipe for target 'CMakeFiles/Mono.dir/all' failed make[1]: *** [CMakeFiles/Mono.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/Stereo.dir/all' failed make[1]: *** [CMakeFiles/Stereo.dir/all] Error 2 make[2]: *** No rule to make target '../../../../lib/libboost_filesystem.so', needed by '../RGBD'. Stop. CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/RGBD.dir/all' failed make[1]: *** [CMakeFiles/RGBD.dir/all] Error 2 make[2]: *** No rule to make target '../../../../lib/libboost_filesystem.so', needed by '../MonoAR'. Stop. CMakeFiles/Makefile2:820: recipe for target 'CMakeFiles/MonoAR.dir/all' failed make[1]: *** [CMakeFiles/MonoAR.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

But below resolved

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

gnykumar avatar Jan 15 '19 07:01 gnykumar

Just adding -lboost_system to set(LIBS... directive in Examples/ROS/ORB_SLAM2/CMakeLists.txt worked for me!

positron96 avatar Apr 11 '19 07:04 positron96

Ok, I got confused. Remove all the flags in that CMakeList. I see that this CMakeList is the principal, you should do the changes in the ROS CMakeList. I think that is here: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeList.txt

It should have this:

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

@AldrichCabrera Thank you!

Thank you!!

kimkt0408 avatar May 16 '19 09:05 kimkt0408

@AldrichCabrera, thank you so much! That really solved my problem :) :+1:

Gentser avatar May 25 '19 11:05 Gentser

think you very much! I have spent the whole day on this !

xkaneiki avatar Jul 06 '19 05:07 xkaneiki

thx @AldrichCabrera , it help me a lot !

CHOUUUUUUUUU avatar Jul 16 '19 09:07 CHOUUUUUUUUU

thx @AldrichCabrera ,it is very useful!

lijinglin-star avatar Feb 12 '20 05:02 lijinglin-star

Fixed! Thanks @AldrichCabrera.

sahiedu avatar Mar 26 '20 16:03 sahiedu

Just a note if you want to use the cmake module for boost to link the library, modifying the cmake file at Examples/ROS/ORB_SLAM2/CMakeList.txt as follows worked for me (modifications are in bold):

find_package(Eigen3 3.1.0 REQUIRED) find_package(Pangolin REQUIRED) find_package(Boost REQUIRED COMPONENTS system)

include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/../../../ ${PROJECT_SOURCE_DIR}/../../../include ${Pangolin_INCLUDE_DIRS} )

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${Boost_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so )

gidobot avatar Jun 09 '20 21:06 gidobot

Ok, I got confused. Remove all the flags in that CMakeList. I see that this CMakeList is the principal, you should do the changes in the ROS CMakeList. I think that is here: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeList.txt

It should have this:

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

Great!

hdd0723 avatar Sep 25 '20 07:09 hdd0723

Ok, I got confused. Remove all the flags in that CMakeList. I see that this CMakeList is the principal, you should do the changes in the ROS CMakeList. I think that is here: /home/teun/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeList.txt

It should have this:

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system )

Thank You! 🔥❤️

ramithuh avatar Jan 27 '21 13:01 ramithuh

remember to add -lboost_system under line 59 set(.....) such as include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/../../../ ${PROJECT_SOURCE_DIR}/../../../include ${Pangolin_INCLUDE_DIRS} )

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system #Pay attention here )

IMHinnG avatar Sep 12 '21 04:09 IMHinnG

change this file:

/home/xxx/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/CMakeLists.txt

cmake_minimum_required(VERSION 2.4.6) include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()

IF(NOT ROS_BUILD_TYPE) SET(ROS_BUILD_TYPE Release) ENDIF()

MESSAGE("Build type: " ${ROS_BUILD_TYPE})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -march=native ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -march=native")

Check C++11 or C++0x support

include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions(-DCOMPILEDWITHC11) message(STATUS "Using flag -std=c++11.") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") add_definitions(-DCOMPILEDWITHC0X) message(STATUS "Using flag -std=c++0x.") else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../../cmake_modules)

find_package(OpenCV 3.0 QUIET) if(NOT OpenCV_FOUND) find_package(OpenCV 2.4.3 QUIET) if(NOT OpenCV_FOUND) message(FATAL_ERROR "OpenCV > 2.4.3 not found.") endif() endif()

find_package(Eigen3 3.1.0 REQUIRED) find_package(Pangolin REQUIRED)

find_package(Boost COMPONENTS filesystem system REQUIRED)#加在其他find_package下面 set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${Boost_LIBRARIES} #加的是这句 ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so )

include_directories( ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/../../../ ${PROJECT_SOURCE_DIR}/../../../include ${Pangolin_INCLUDE_DIRS} )

set(LIBS ${OpenCV_LIBS} ${EIGEN3_LIBS} ${Pangolin_LIBRARIES} ${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so ${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so ${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so -lboost_system #需要添加到这个地方,一开始添加到了上面的set(LIBS),结果一直报错 )

Node for monocular camera

rosbuild_add_executable(Mono src/ros_mono.cc )

target_link_libraries(Mono ${LIBS} )

Node for monocular camera (Augmented Reality Demo)

rosbuild_add_executable(MonoAR src/AR/ros_mono_ar.cc src/AR/ViewerAR.h src/AR/ViewerAR.cc )

target_link_libraries(MonoAR ${LIBS} )

Node for stereo camera

rosbuild_add_executable(Stereo src/ros_stereo.cc )

target_link_libraries(Stereo ${LIBS} )

Node for RGB-D camera

rosbuild_add_executable(RGBD src/ros_rgbd.cc )

target_link_libraries(RGBD ${LIBS} )

AlanWu857 avatar Nov 30 '21 07:11 AlanWu857