error: undefined reference to symbol '_ZN5boost6system15system_categoryEv

使用boost时遇到下面error:      

cmake version : 3.5.1

/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

原因:libboost_system未被包含

解决:

修改CMakelists.txt:

将         find_package( Boost REQUIRED )

改为     find_package(  Boost REQUIRED COMPONENTS filesystem )

 

注:在cmake2.X中没出现这个问题,在cmake3.X中出现,可能是cmake 修改了相关默认项

你可能感兴趣的:(linux,c++)