Debug:'boost::this_thread' has not been declared; undefined reference to 'boost::this_thread...'

今天解决两个C++编译工程时的BUG。

问题1描述
编译到某个.cpp文件时,报'boost::this_thread' has not been declared; ,这个很明显是这个.cpp文件没有找到boost库里的这个函数的问题。

解决方法
在该.cpp文件或者对应的.h文件中,添加下面的头文件引用:

#include <boost/thread/thread.cpp>

再次编译时,就不会再报这个错误了。

问题2描述
编译完所有文件,开始链接时,报undefined reference to 'boost::this::hidden::sleep_until(timespec const&)',这个也是老错误了,多半是CMakeLists.txt文件里没有配置boost库,或者没有把boost库链接到target上。

解决方法
在CMakeLists.txt中添加配置:

find_package(Boost REQUIRED COMPONENTS thread)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
add_definitions(-DBOOST_ALL_DYN_LINK)// 要把上面的库链接到可执行文件
target_link_libraries(main ${Boost_LIBRARIES})

再次编译链接,就不会报这个错了。

Debug:‘boost::this_thread‘ has not been declared; undefined reference to ‘boost::this_thread...‘相关推荐

  1. undefined reference to `boost::system::generic_category()

    报错大致如下: main.cpp:(.text+0x49): undefined reference to `boost::system::generic_category()' main.cpp:( ...

  2. boost的libboost_system问题 undefined reference to `boost::system::generic_categor

    最近把cpp代码从开发机放到编译机去,遇到了不少路径问题. 安装boost的时候,其实很简单 wget http://sourceforge.net/projects/boost/files/boos ...

  3. 解决libresource_retriever.so:对‘curl_easy_init@CURL_OPENSSL_3’未定义的引用 ,undefined reference to `uuid_gene

    解决libresource_retriever.so:对'curl_easy_init@CURL_OPENSSL_3'未定义的引用 /usr/lib/x86_64-linux-gnu/libapr-1 ...

  4. cmake出现undefined reference to `boost::this_thread::hiden::sleep_until(timespec const)‘

    如果不是你没有链接boost的问题那就是版本问题,我用的boost1.61出现了这个问题,然后使用boost1.53就不会出错了

  5. undefined reference to “boost” in Qt—Ubuntu

    一:使用PCL时遇到的问题 原因:缺少boost的lib包含: 在Pro文件里面添加: LIBS += -lboost_system .....................等库文件包含 二:编译B ...

  6. debug:g2o cmake时报错“Qt5 not found. Install it and set Qt5_DIR accordingly

    ** debug:g2o cmake时报错"Qt5 not found. Install it and set Qt5_DIR accordingly" ** 完整报错: @ubu ...

  7. 错误:Element type “select“ must be declared.

    在刚刚学习ibatis时,使用的jar包是ibatis-sqlmap-2.3.4.726-sources.jar,一运行就碰到了异常:Element type "select" m ...

  8. React实践debug:JSX输出的限制(存疑)

    今天在练习React构建组件的时候遇到一个问题. 由于文档中反复提倡将组件尽可能按功能单位分解复用.在练习用React做一个todolist时候,我把todolist分解成两部分: class Tod ...

  9. boost::bind with ros action,ros中SimpleActionServer用boost::bind绑定多个参数

    boost::bind with ros action,ros中SimpleActionServer用boost::bind绑定多个参数 #include <unistd.h> //参数: ...

最新文章

  1. Source Code Collection for Reproducible Research
  2. notepad++的NppFTP插件远程连接linux操作系统
  3. save()、saveOrUpdate()、merge()的区别
  4. java s1_转!!Java 基础面试题的剖析: short s1=1;s1 = s1 +1 报错? s1+=1 呢
  5. springboot的缓存技术
  6. 认真聊一下MySQL索引的底层实现!
  7. 超融合带来的IT人员问题 企业是否看到?
  8. Uniswap 24h交易量约11.2亿美元涨23.91%
  9. 赛锐信息:PM模块的几点看法
  10. 优化大中型企业Internet连接
  11. 【Android -- 数据存储】LitePal 的基本使用
  12. 雷达线雕的原理及功效
  13. 开源数据库连接池的使用
  14. java 实现 PTF远程连接带有中文下载,解决文件损失
  15. 小米android微博授权管理工具下载,微博推广:第三方微博工具,微博管理工具:微博粉丝管理工具!...
  16. shell脚本 sh shebang “#!/bin/sh“
  17. 魔法币 java_网易2018校招笔试编程题-魔法币 java实现
  18. Android AOP 编程实践 javapoet + autoService
  19. AVR单片机及其编译软件
  20. 管理Kindle的“我的剪切”

热门文章

  1. HTML 全页面内容自由编辑与 HTML 页面全部黑白风格处理
  2. php选择手机相片,头像直接从手机图库选择或者拍照上传
  3. Linux系统用C语言设计酒店管理系统
  4. 一篇3分文章的水稻转录组分析实战
  5. 港科百创|【未磁科技】勇夺百万大奖,2021年度总决赛圆满收官!香港科大-越秀集团百万奖金国际创业大赛年度总决赛成功举办!...
  6. android 自定义特效,Android 自定义控件~流光特效
  7. 西门子博图功能指令——Array数据中元素的读取
  8. 8251A可编程串行接口
  9. 求函数:x的n次方(函数递归)
  10. win11修改C盘用户文件夹名称