找不到以下Boost库:boost_system

时间:2019-01-26 13:46:13

标签: c++ boost build cmake

我想建立这个仓库:https://github.com/reo7sp/tgbot-cpp

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

我如何安装库和cmake

Boost编译为:

bootstrap.bat
.\b2

和(因为我不知道区别;一个在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)

没有任何效果。我绝对不知道该做什么,因为几天来拼命地试图弄清楚该怎么做才能成功。请帮帮我。

2 个答案:

答案 0 :(得分:0)

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

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

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

答案 1 :(得分:0)

使用相同的命令来构建和安装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

现在应该可以工作。