Ubuntu展示点云使用boost::this_thread报错

Ubuntu使用boost::this_thread展示点云

 boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer(new pcl::visualization::PCLVisualizer("3D Viewer"));viewer->setBackgroundColor(180, 180, 180);viewer->addCoordinateSystem(1.0);viewer->initCameraParameters();pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> color_right(cloud_right, 255, 0, 0);viewer->addPointCloud<pcl::PointXYZI>(cloud_right, color_right, "cloud_right");pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZI> color_left(cloud_left, 0, 0, 255);viewer->addPointCloud<pcl::PointXYZI>(cloud_left, color_left, "cloud_left");while (!viewer->wasStopped()){viewer->spinOnce(100);boost::this_thread::sleep (boost::posix_time::microseconds (100000));//boost::thread::sleep(boost::get_system_time() + boost::posix_time::seconds(5));}return;

头文件没有加boost的任何头文件,make时报错boost::this_thread’ has not been declared

/home/qiancj/Desktop/ShareFolder/5Codes/Cluster_ExtractCentrepoint/Cluster_ExtractCentrepoint.cc: In function ‘int main(int, char**)’:
/home/qiancj/Desktop/ShareFolder/5Codes/Cluster_ExtractCentrepoint/Cluster_ExtractCentrepoint.cc:277:16: error: ‘boost::this_thread’ has not been declaredboost::this_thread::sleep(boost::posix_time::microseconds(100000));^~~~~~~~~~~
CMakeFiles/Cluster_ExtractCentrepoint.dir/build.make:62: recipe for target 'CMakeFiles/Cluster_ExtractCentrepoint.dir/Cluster_ExtractCentrepoint.cc.o' failed
make[2]: *** [CMakeFiles/Cluster_ExtractCentrepoint.dir/Cluster_ExtractCentrepoint.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Cluster_ExtractCentrepoint.dir/all' failed
make[1]: *** [CMakeFiles/Cluster_ExtractCentrepoint.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

头文件中增加boost的头文件

#include <boost/thread/thread.hpp>

make时报错undefined reference to boost::this_thread::hidden::sleep_until(timespec const&)

CMakeFiles/Cluster_ExtractCentrepoint.dir/Cluster_ExtractCentrepoint.cc.o: In function `boost::this_thread::sleep(boost::posix_time::ptime const&)':
Cluster_ExtractCentrepoint.cc:(.text._ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE[_ZN5boost11this_thread5sleepERKNS_10posix_time5ptimeE]+0x37): undefined reference to `boost::this_thread::hidden::sleep_until(timespec const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/Cluster_ExtractCentrepoint.dir/build.make:197: recipe for target 'Cluster_ExtractCentrepoint' failed
make[2]: *** [Cluster_ExtractCentrepoint] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Cluster_ExtractCentrepoint.dir/all' failed
make[1]: *** [CMakeFiles/Cluster_ExtractCentrepoint.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Method 1

需要在cmake之后,修改生成的项目.dir目录下link.txt文件:

在文件最后增加

-lboost_thread

Method 2

方法1就是添加了boost_thread的链接,所以直接在CmakeLists.txt文件中添加即可

find_package(Boost 1.65.1 REQUIRED COMPONENTS thread) # 我的boost版本是1.65.1的
IF (Boost_FOUND)INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})Message(STATUS, "PRINT BOOST: ${Boost_INCLUDE_DIR}")Message(STATUS, "PRINT BOOST: ${Boost_THREAD_LIBRARY}")ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()
target_link_libraries (ProjectName ${Boost_THREAD_LIBRARY})

cmake之后,再打开link.txt文件,发现新增了/usr/lib/x86_64-linux-gnu/libboost_thread.so动态库

编译成功:

以上。

ubuntu展示点云使用boost::this_thread报错相关推荐

  1. Hbuilder无法完成应用程序云打包,一直报错需要打包校验

    解决办法: 不要在上述链接中进行验证,因为会一直收不到手机验证短信. 在 https://dev.dcloud.net.cn/user/profile 中进行验证,亲测有用. 相关链接 1.MUI的简 ...

  2. 解决navicat连接阿里云服务器的mysql报错:1130 . Host 16.8 85 isnot alowed to con nect to this MySQL server

    解决navicat连接阿里云服务器的mysql报错:1130 . Host 16.8 85 isnot alowed to con nect to this MySQL server 报错效果 报错原 ...

  3. Python3解决问题:编写词云代码,总是报错

    Python3解决问题:编写词云代码,总是报错 代码 #GovRptWordCloudv1.py import jieba import wordcloud f = open("gr.txt ...

  4. Debian/Ubuntu 对gpg和apt-key使用代理--报错解决:gpg: keyserver receive failed: Connection timed out

    gpg和apt-key使不会直接读取终端中设置的代理,需要单独设置. 参考地址:bash - keyserver timed out when trying to add a GPG public k ...

  5. git第一次提交代码到码云,git pull 报错:fatal: refusing to merge unrelated histories

    第一次提交的步骤: 1.进入项目目录,执行 git init 2.连接远程仓库 git remote add origin 远程仓库地址(从码云乎哟这github上复制地址即可) 3.报错:git p ...

  6. Ubuntu apt update(apt-get update)报错、失败

    报错截图 在ubuntu16中,当我们输入sudo apt-get update会失败,这里有很多原因 (1)网络原因----先检查网络好不好用 (2)ubuntu16 自带的源不好用,或者有问题 我 ...

  7. Ubuntu 16.04 - 64bit 解压 rar 报错 Parsing Filters not supported

    Ubuntu 16.04 - 64bit  解压rar 文件报错: 错误如下图: 原因: 未安装解压命令 unrar 参考博客: Error - "Parsing Filters not s ...

  8. 云服务器zabbix server报错:Lack of free swap on Zabbix server

    1.问题 Lack of free swap space on Zabbix server 在监控云主机的时候经常会遇到这种情况,虽然内存基本没用,但是就是提示这个消息 因为zabbix不 会考虑云主 ...

  9. Ubuntu18.04之boost警告报错

    报错: dpkg: 警告: 无法找到软件包 libboost-locale-dev:amd64 的文件名列表文件,现假定该软件包目前没有任何文件被安装在系统里. dpkg: 警告: 无法找到软件包 l ...

最新文章

  1. 内存分配策略(一):JVM栈桢及方法调用详解
  2. 计算机应用基础851,清华大学851西方经济学考研参考书目及考研真题
  3. [SPDK/NVMe存储技术分析]012 - 用户态ibv_post_send()源码分析
  4. 树和二叉树的转换代码python_python数据结构之二叉树的统计与转换实例
  5. 模块式开发 java_Java9系列第8篇-Module模块化编程
  6. Log4Net 配置日志按日期和日志级别分类写入
  7. matplotlib 可视化细节,丰富的可选参数
  8. 优秀!文件备份工具——IDrive for Mac
  9. 如何解决CAN FD与CAN网络共存问题
  10. 88个塑胶模具设计中常用的知识点
  11. STM8L152K4T6原理图与开发程序
  12. 股票中的KDJ三根线分别代表什么?
  13. 基于Python的jieba分词和词云展示
  14. html的后代选择器,CSS3后代选择器和同级选择器简介和实例_html/css_WEB-ITnose
  15. Java和C语言有什么区别?
  16. 关于三子棋游戏的简易实现与N子棋胜利判断方法
  17. 公司章程违反了公司法该怎么办
  18. Python 使用 opencv 库将BMP格式图片转RAW
  19. PCIe LTSSM 之 Detect 状态
  20. GPS卫星同步时钟(GPS授时服务器)在校园网络里的应用

热门文章

  1. Ural1671 Anansi's Cobweb
  2. activity组任务使用
  3. python pandas读取excel时动态确定标题行所在行数
  4. 谁知道下面这个视频中的特效是用什么软件做的?
  5. 大数据之Hadoop简介及环境搭建
  6. 推荐系统之AFM代码详解
  7. 码云新建仓库-代码上传
  8. 试卷代号:4988 2021年春季学期期末统一考试电子政务概论 试题(开卷)
  9. 全新电影社交观影,满足影迷移动巨幕与移动3D体验
  10. linux gtestgmock安装