鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    使用catkin_make编译时提示boost下的thread出错,请问要怎么解决

    已定时 已固定 已锁定 已移动 未解决
    综合问题
    boost thread catkinmake
    2
    11
    1.0k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • chestnutlC
      chestnutl
      最后由 编辑

      In file included from /usr/include/boost/thread/detail/platform.hpp:17,
                       from /usr/include/boost/thread/mutex.hpp:12,
                       from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/filter2move_frame_sum.cpp:1:
      /usr/include/boost/config/requires_threads.hpp:47:5: error: #error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
         47 | #   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
            |     ^~~~~
      In file included from /usr/include/boost/thread/mutex.hpp:12,
                       from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/filter2move_frame_sum.cpp:1:
      /usr/include/boost/thread/detail/platform.hpp:71:9: error: #error "Sorry, no boost threads are available for this platform."
         71 | #       error "Sorry, no boost threads are available for this platform."
            |         ^~~~~
      In file included from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/filter2move_frame_sum.cpp:1:
      /usr/include/boost/thread/mutex.hpp:18:2: error: #error "Boost threads unavailable on this platform"
         18 | #error "Boost threads unavailable on this platform"
            |  ^~~~~
      In file included from /usr/include/boost/thread/detail/platform.hpp:17,
                       from /usr/include/boost/thread/mutex.hpp:12,
                       from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/detach_box.cpp:1:
      /usr/include/boost/config/requires_threads.hpp:47:5: error: #error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
         47 | #   error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
            |     ^~~~~
      In file included from /usr/include/boost/thread/mutex.hpp:12,
                       from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/detach_box.cpp:1:
      /usr/include/boost/thread/detail/platform.hpp:71:9: error: #error "Sorry, no boost threads are available for this platform."
         71 | #       error "Sorry, no boost threads are available for this platform."
            |         ^~~~~
      In file included from /opt/ros/noetic/include/ros/publisher.h:36,
                       from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/detach_box.cpp:1:
      /usr/include/boost/thread/mutex.hpp:18:2: error: #error "Boost threads unavailable on this platform"
         18 | #error "Boost threads unavailable on this platform"
            |  ^~~~~
      In file included from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/detach_box.cpp:1:
      /opt/ros/noetic/include/ros/publisher.h:204:14: error: ‘mutex’ in namespace ‘boost’ does not name a type
        204 |       boost::mutex last_message_mutex_;
            |              ^~~~~
      In file included from /opt/ros/noetic/include/ros/node_handle.h:32,
                       from /opt/ros/noetic/include/ros/ros.h:45,
                       from /home/chestnutl/xiaoche_ws/src/opencv_object_tracking/src/filter2move_frame_sum.cpp:1:
      /opt/ros/noetic/include/ros/publisher.h:204:14: error: ‘mutex’ in namespace ‘boost’ does not name a type
        204 |       boost::mutex last_message_mutex_;
            |              ^~~~~
      make[2]: *** [opencv_object_tracking/CMakeFiles/detach_box.dir/build.make:63:opencv_object_tracking/CMakeFiles/detach_box.dir/src/detach_box.cpp.o] 错误 1
      make[1]: *** [CMakeFiles/Makefile2:2959:opencv_object_tracking/CMakeFiles/detach_box.dir/all] 错误 2
      make[1]: *** 正在等待未完成的任务....
      make[2]: *** [opencv_object_tracking/CMakeFiles/filter2move_frame_sum.dir/build.make:63:opencv_object_tracking/CMakeFiles/filter2move_frame_sum.dir/src/filter2move_frame_sum.cpp.o] 错误 1
      make[1]: *** [CMakeFiles/Makefile2:2480:opencv_object_tracking/CMakeFiles/filter2move_frame_sum.dir/all] 错误 2
      make: *** [Makefile:141:all] 错误 2
      Invoking "make -j8 -l8" failed
      
      
      小鱼小 1 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @chestnutl
        最后由 编辑

        @chestnutl 应该没有开启boost库里的线程组件

        @chestnutl 在 使用catkin_make编译时提示boost下的thread出错,请问要怎么解决 中说:

        Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris)

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        chestnutlC 2 条回复 最后回复 回复 引用 0
        • chestnutlC
          chestnutl @小鱼
          最后由 编辑

          @小鱼 嗯嗯,请问应当如何解决呢

          1 条回复 最后回复 回复 引用 0
          • chestnutlC
            chestnutl @小鱼
            最后由 编辑

            @小鱼 快查了两天了,都没找到怎么解决这个,麻了

            小鱼小 1 条回复 最后回复 回复 引用 0
            • 小鱼小
              小鱼 技术大佬 @chestnutl
              最后由 编辑

              @chestnutl 这个要看你工程了,具体需要添加类似于下面的内容

              
              ## System dependencies are found with CMake's conventions
              find_package(Boost REQUIRED COMPONENTS
                  thread
              )
               
              if(NOT Boost_FOUND)
                  message("NOT found Boost")
              endif()
               
              include_directories(${Boost_INCLUDE_DIRS})
              # Declare the executable target built from your sources
              add_executable(${PROJECT_NAME} src/test_main.cpp)
              target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
              

              新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

              chestnutlC 2 条回复 最后回复 回复 引用 0
              • chestnutlC
                chestnutl @小鱼
                最后由 编辑

                @小鱼 哦哦,但是我之前编译同一个工作空间的时候没加这个也能编译成功啊

                小鱼小 1 条回复 最后回复 回复 引用 0
                • 小鱼小
                  小鱼 技术大佬 @chestnutl
                  最后由 编辑

                  @chestnutl 同一个工作空间catkin用的同一个cmake,把依赖放一起了,具体你可能需要学习下catkin编译的原理和流程。

                  新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                  chestnutlC 1 条回复 最后回复 回复 引用 0
                  • chestnutlC
                    chestnutl @小鱼
                    最后由 编辑

                    @小鱼 哦哦,好的。感谢

                    1 条回复 最后回复 回复 引用 0
                    • chestnutlC
                      chestnutl @小鱼
                      最后由 编辑

                      @小鱼 我在功能包的cmakelist内加了上面这一段编译也不通过啊

                      小鱼小 1 条回复 最后回复 回复 引用 0
                      • 小鱼小
                        小鱼 技术大佬 @chestnutl
                        最后由 编辑

                        @chestnutl 具体情况具体分析,我只能跟你说个大概方向 ,代码怎么写的、工程什么结构、系统什么版本,具体的调试起来才能解决,这些需要你自己去做的。

                        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

                        chestnutlC 1 条回复 最后回复 回复 引用 0
                        • chestnutlC
                          chestnutl @小鱼
                          最后由 编辑

                          @小鱼 哦哦,好的

                          1 条回复 最后回复 回复 引用 0
                          • 第一个帖子
                            最后一个帖子
                          皖ICP备16016415号-7
                          Powered by NodeBB | 鱼香ROS