【报错】undefined reference to `tbb::interface7::internal::isolate_within_arena(tbb::interface7::interna

在编译高博《自动驾驶与机器人中的SLAM技术》ch3时,出现报错:

../../../lib/libslam_in_auto_driving.tools.so: undefined reference to `tbb::interface7::internal::isolate_within_arena(tbb::interface7::internal::delegate_base&, long)'
collect2: error: ld returned 1 exit status
src/tools/CMakeFiles/ui_test.dir/build.make:833: recipe for target '../bin/ui_test' failed
make[2]: *** [../bin/ui_test] Error 1
CMakeFiles/Makefile2:3829: recipe for target 'src/tools/CMakeFiles/ui_test.dir/all' failed
make[1]: *** [src/tools/CMakeFiles/ui_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 94%] Built target slam_in_auto_driving.common
Makefile:145: recipe for target 'all' failed
make: *** [all] Error 2

前置条件:电脑已经将GCC升级到了9+版本
报错提示是未链接到tbb的库,当使用find_package(tbb)或者find_package(TBB)时,CMake提示无法找到这个库

解决办法:
src/tools/CMakeLists.txt中的两个target_link_libraries()直接链接tbb的相关库文件:

        /usr/local/lib/libtbb.so
        /usr/local/lib/libtbbmalloc.so
        /usr/local/lib/libtbbmalloc_proxy.so

完整的CMakeLists.txt如下:

add_library(${PROJECT_NAME}.tools
        pointcloud_convert/velodyne_convertor.cc
        pointcloud_convert/packets_parser.cc
        ui/pangolin_window.cc
        ui/pangolin_window_impl.cc
        ui/ui_car.cc
        ui/ui_trajectory.cc
        ui/ui_cloud.cc
        )

target_link_libraries(${PROJECT_NAME}.tools
# lusx add
        /usr/local/lib/libtbb.so
        /usr/local/lib/libtbbmalloc.so
        /usr/local/lib/libtbbmalloc_proxy.so

        ${third_party_libs}
        )

add_executable(ui_test ui/ui_test.cc)
target_link_libraries(ui_test
# lusx add
        /usr/local/lib/libtbb.so
        /usr/local/lib/libtbbmalloc.so
        /usr/local/lib/libtbbmalloc_proxy.so

        ${PROJECT_NAME}.tools
        ${third_party_libs}
        )
  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值