undefined reference to `SCManager::makeAndSaveRinghashAndKeys(pcl::PointCloud<pcl::PointXYZI>&)‘col

问题描述:

用catking_make在编译代码时候遇到以下错误:

(base) xdh@Pc:~/SLAM/std_ws$ catkin_make
Base path: /home/xdh/SLAM/std_ws
Source space: /home/xdh/SLAM/std_ws/src
Build space: /home/xdh/SLAM/std_ws/build
Devel space: /home/xdh/SLAM/std_ws/devel
Install space: /home/xdh/SLAM/std_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/xdh/SLAM/std_ws/build"
####
####
#### Running command: "make -j8 -l8" in "/home/xdh/SLAM/std_ws/build"
####
Scanning dependencies of target mytest
[ 20%] Built target pgo_demo
[ 40%] Built target online_demo
[ 60%] Built target place_recognition_livox
[ 80%] Built target place_recognition_kitti
[ 86%] Building CXX object STD/CMakeFiles/mytest.dir/demo/my_test.cpp.o
/home/xdh/SLAM/std_ws/src/STD/demo/my_test.cpp: In function ‘int main(int, char**)’:
/home/xdh/SLAM/std_ws/src/STD/demo/my_test.cpp:120:42: error: ‘t_descript’ was not declared in this scope; did you mean ‘t_descriptor_end’?
  120 |       descriptor_time.push_back(time_inc(t_descript             n      or_end, t_descriptor_begin));
      |                                          ^~~~~~~~~~
      |                                          t_descriptor_end
make[2]: *** [STD/CMakeFiles/mytest.dir/build.make:63:STD/CMakeFiles/mytest.dir/demo/my_test.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:570:STD/CMakeFiles/mytest.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j8 -l8" failed
(base) xdh@Pc:~/SLAM/std_ws$ catkin_make
Base path: /home/xdh/SLAM/std_ws
Source space: /home/xdh/SLAM/std_ws/src
Build space: /home/xdh/SLAM/std_ws/build
Devel space: /home/xdh/SLAM/std_ws/devel
Install space: /home/xdh/SLAM/std_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/xdh/SLAM/std_ws/build"
####
####
#### Running command: "make -j8 -l8" in "/home/xdh/SLAM/std_ws/build"
####
Scanning dependencies of target mytest
[ 20%] Built target online_demo
[ 40%] Built target place_recognition_livox
[ 60%] Built target pgo_demo
[ 80%] Built target place_recognition_kitti
[ 86%] Building CXX object STD/CMakeFiles/mytest.dir/demo/my_test.cpp.o
[ 93%] Linking CXX executable /home/xdh/SLAM/std_ws/devel/lib/std_detector/mytest
/usr/bin/ld: CMakeFiles/mytest.dir/demo/my_test.cpp.o: in function `main':
my_test.cpp:(.text.startup+0x1508): undefined reference to `SCManager::makeAndSaveRinghashAndKeys(pcl::PointCloud<pcl::PointXYZI>&)'
collect2: error: ld returned 1 exit status
make[2]: *** [STD/CMakeFiles/mytest.dir/build.make:523:/home/xdh/SLAM/std_ws/devel/lib/std_detector/mytest] 错误 1
make[1]: *** [CMakeFiles/Makefile2:570:STD/CMakeFiles/mytest.dir/all] 错误 2
make: *** [Makefile:141:all] 错误 2
Invoking "make -j8 -l8" failed

后经过上网查找,发现这一般都是连接错误,错误的问题是编译器没有找到需要的代码文件,一般就是cmakelists.txt文件中的错误

解决方法:

修改之前和之后的代码:

add_executable(mytest demo/my_test.cpp src/STDesc.cpp)
target_link_libraries(mytest 
        ${catkin_LIBRARIES} 
        ${PCL_LIBRARIES} 
        ${OpenCV_LIBS} 
        ${CERES_LIBRARIES})
add_executable(mytest demo/my_test.cpp src/STDesc.cpp demo/Scancontext.cpp)
target_link_libraries(mytest 
        ${catkin_LIBRARIES} 
        ${PCL_LIBRARIES} 
        ${OpenCV_LIBS} 
        ${CERES_LIBRARIES})

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值