【问题标题】:Unable to find the requested Boost libraries boost_lboost_thread找不到请求的 Boost 库 boost_lboost_thread
【发布时间】:2018-05-24 13:23:54
【问题描述】:

我一直在尝试在 CMake 环境中运行 Qt 项目。 Qt 项目正在使用 openCV 和 Boost 依赖项。在成功解决所有编译错误后,我一直在努力解决 Boost 错误。 一旦我运行 CMake,我就会收到以下错误:

在 /home/labrat/Desktop/cam-proc/build 中运行“/usr/bin/cmake /home/labrat/Desktop/cam-proc '-GCodeBlocks - Unix Makefiles'”。

**CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):**
  Unable to find the requested Boost libraries.

  Boost version: 1.58.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_lboost_thread

  Some (but not all) of the required Boost libraries were found.  You may
  need to install these additional Boost libraries.  Alternatively, set
  BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
  to the location of Boost.
**Call Stack (most recent call first):
  src/libCam/CMakeLists.txt:7 (find_package)**

Boost version: 1.58.0

Found the following Boost libraries:

       system
       thread
       filesystem
       chrono
       date_time
       atomic

-- Configuring incomplete, errors occurred!
See also "/home/labrat/Desktop/cam-proc/build/CMakeFiles/CMakeOutput.log".
See also "/home/labrat/Desktop/cam-proc/build/CMakeFiles/CMakeError.log".
*** cmake process exited with exit code 1.

我分析了 CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message): 的错误并打开了巨大的 FindBoost.cmake 文件,根据警告,这是错误所在的部分:

message(SEND_ERROR "找不到请求的 Boost 库。\n${Boost_ERROR_REASON}")

  # Add pthread library on UNIX if thread component was found
  _Boost_consider_adding_pthreads(Boost_LIBRARIES ${Boost_LIBRARIES})
else()
  if(Boost_FIND_REQUIRED)
    message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}")
  else()
    if(NOT Boost_FIND_QUIETLY)
      # we opt not to automatically output Boost_ERROR_REASON here as
      # it could be quite lengthy and somewhat imposing in its requests
      # Since Boost is not always a required dependency we'll leave this
      # up to the end-user.
      if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG)
        message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}")
      else()
        message(STATUS "Could NOT find Boost")
      endif()
    endif()
  endif()
endif()

另外,由于错误消息的另一部分说 调用堆栈(最近的调用优先):src/libCam/CMakeLists.txt:7 (find_package) 在这里我将 CMakeLists.txt 附加到libcam 项目(如果有帮助):

cmake_minimum_required (VERSION 2.8.12)
project(libCam)
find_package(Qt5Widgets REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Boost COMPONENTS filesystem lboost_thread system REQUIRED)
find_package(Boost COMPONENTS system thread filesystem REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
###
# make sure we use c++11
###
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})

include_regular_expression("^([^b]|b[^o]|bo[^o]|boo[^s]|boos[^t]|boost[^/]).*$")

qt5_wrap_ui (UIS_HDRS  qtinclude/imagemanager.ui qtinclude/stereomanager.ui qtinclude/stereolistwidget.ui qtinclude/connectionmenu.ui)

file(GLOB LIBCAM_SRCS
    "include/*.h"
    "include/*.cpp"
    "include/*.hpp"
    "qtinclude/*.h"
    "qtinclude/*.cpp"
    "qtinclude/*.hpp"
)

file(GLOB UI_RC
  "qtinclude/qdarkstyle/*.qrc"
)

add_library(libCam SHARED ${LIBCAM_SRCS} ${UIS_HDRS} ${UI_RC})
target_include_directories (libCam  PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
target_link_libraries (libCam  Qt5::Widgets  Qt5::PrintSupport Qt5::Core Qt5::Quick Qt5::Sql Qt5::XmlPatterns ${Boost_LIBRARIES} ${OpenCV_LIBS} )

过去两天我一直在谷歌上搜索错误,寻找解决这个问题的信息和代码,但我的想法已经不多了。我尝试下载 boost 1.55 但它不起作用,因为编译器只能看到 boost 1.58。

知道如何阐明这件事吗?有什么我要遗漏的吗?

【问题讨论】:

  • 错误试图告诉你lboost_thread 不是Boost 组件!从您的 find_package 调用中删除它,删除 CMakeCache.txt 并重试。
  • 感谢 vre CMake 正在编译!

标签: c++ boost cmake qt5


【解决方案1】:

问题是线

find_package(Boost COMPONENTS filesystem lboost_thread system REQUIRED)

应该改成

find_package(Boost COMPONENTS filesystem thread system REQUIRED)

或者干脆删除,因为它相当于下面一行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 2019-02-06
    • 2018-08-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多