【问题标题】:Could not find the following Boost libraries: boost_system找不到以下 Boost 库: boost_system
【发布时间】:2019-06-20 02:18:34
【问题描述】:

我想构建这个存储库:https://github.com/reo7sp/tgbot-cpp

它是一个用于管理 Telegram 机器人的 API。所需的依赖项是 openssl、zlib、boost。卷曲是可选的。

我是如何安装库和 cmake 的

Boost 编译时使用:

bootstrap.bat
.\b2

and(因为我不知道区别;一个在 boost/stage/lib 下编译;第二个在 boost/lib 下)

bjam install --prefix=D:/Programme/Boost/boost_1_69_0 --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi

我在path下的系统变量中添加了所需的路径。

environment variables

Path

尝试使用 cmake 构建时出现以下错误:

The C compiler identification is MSVC 19.16.27026.1
The CXX compiler identification is MSVC 19.16.27026.1
Check for working C compiler: D:/Programme (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
Check for working C compiler: D:/Programme (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: D:/Programme (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
Check for working CXX compiler: D:/Programme (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE  
Found ZLIB: D:/Programme (x86)/GnuWin32/lib/zlib.lib (found version "1.2.3") 
Found OpenSSL: optimized;D:/Programme/OpenSSL-Win64/lib/VC/libcrypto64MD.lib;debug;D:/Programme/OpenSSL-Win64/lib/VC/libcrypto64MDd.lib (found version "1.1.0j")  
Could NOT find CURL (missing: CURL_LIBRARY) (found version "7.63.0")
CMake Warning (dev) at CMakeLists.txt:62 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Environment variable Boost_ROOT is set to:

    D:\Programme\Boost\boost_1_69_0

  For compatibility, CMake is ignoring the variable.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at D:/Programme/CMake/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
  Unable to find the requested Boost libraries.

  Boost version: 1.69.0

  Boost include path: D:/Programme/Boost/boost_1_69_0/include/boost-1_69

  Could not find the following Boost libraries:

          boost_system

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.
Call Stack (most recent call first):
  CMakeLists.txt:62 (find_package)


CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CURL_LIBRARY
    linked by target "TgBot" in directory G:/Programmieren (C++)/Bibliotheken/tgbot-cpp-master

Configuring incomplete, errors occurred!
See also "G:/Programmieren (C++)/Bibliotheken/tgbot-cpp-master/BUILD/CMakeFiles/CMakeOutput.log".
See also "G:/Programmieren (C++)/Bibliotheken/tgbot-cpp-master/BUILD/CMakeFiles/CMakeError.log".

在我看来,除了 Boost 之外的一切都有效。我知道有几个用户遇到了这个问题,例如:

Cmake doesn't find Boost

CMake with Boost could not find static libraries

CMake with Boost library Windows 10 Library not found correctly

所以,我做了建议的程序:

SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "D:/Programme/Boost/boost_1_69_0")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "D:/Programme/Boost/boost_1_69_0/lib")

FIND_PACKAGE(Boost)
IF (Boost_FOUND)
    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
    ADD_DEFINITIONS( "-DHAS_BOOST" )
ENDIF()

set(BOOST_LIBRARYDIR D:/Programme/Boost/boost_1_69_0/lib)

没有任何效果。我完全不知道该怎么做,几天来拼命想弄清楚该怎么做而没有成功。请帮帮我。

【问题讨论】:

  • 你自己建立了 boost 吗?不过应该有一个存根升​​压系统。
  • 是的,如上所述。 “存根增强系统”是什么意思?
  • Boost 系统现在只有标题 stackoverflow.com/questions/54184576/…
  • 你能检查一下你是否按预期构建了 boost-system 吗?
  • 对于find_package(Boost),有很好的调试选项-Boost_DEBUG。启用它(例如,使用 -DBoost_DEBUG=1 作为 cmake 选项)允许您检查 Boost 库实际搜索的位置

标签: c++ boost build cmake


【解决方案1】:

使用相同的命令构建和安装 Boost。

bjam install --prefix=D:/Programme/Boost/boost_1_69_0 --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi

在 windows 中,Boost 在 include 下创建另一个子目录。应该是这样的。

D:/Programme/Boost/boost_1_69_0/include/boost-1_69

D:/Programme/Boost/boost_1_69_0/include/boost-1_69中的所有文件移动到D:/Programme/Boost/boost_1_69_0/include/

(将内容上移一个目录)

现在将 CMake 项目中的 BOOST_ROOT 设置为 D:/Programme/Boost/boost_1_69_0

它现在应该可以工作了。

【讨论】:

  • 绝对有效!非常感谢。我花了大约 20 个小时才找到解决方案..
【解决方案2】:

根据您的 cmets,Boost 的位置是 D:/Programme/Boost/boost_1_69_0/stage/lib,但您将其设置为 D:/Programme/Boost/boost_1_69_0/lib

无论如何,如果您将BOOST_ROOT 设置为D:/Programme/Boost/boost_1_69_0FIND_PACKAGE(Boost)(通常是手动,在CMake UI 中而不是在CMakeLists.txt 文件中),则可以找到Boost。

这将依次设置您需要使用的所有Boost_* 变量。

【讨论】:

  • 默认情况下,Cmake 在 stage/lib 中查找 boost 库(我没有手动更改任何内容):imgur.com/q5Tx3ug
  • 在我将 "Boost_DIR" 设置为 "D:\Programme\Boost\boost_1_69_0" 并再次点击 "configure" cmake states Boost_DIR --> "Boost_DIR-NOTFOUND": imgur.com/JQNWg1Y跨度>
  • 显然您的安装或变量有问题。在我使用的任何配置上,这始终是开箱即用的。
猜你喜欢
  • 2014-06-02
  • 2023-03-26
  • 2019-03-29
  • 1970-01-01
  • 2013-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-26
相关资源
最近更新 更多