mongo-c-driver找不到libbson

时间:2016-07-28 19:16:04

标签: mongodb bson mongo-c-driver mongo-cxx-driver

我正在尝试构建mongo-cxx-driver(最终),第一步是构建mongo-c-driver(需要libbson)。

我正在运行Windows 10并使用Visual Studio 2015作为我的编译器。我能够运行CMake并构建libbson就好了所有构建得很好的项目。现在,我有bson-static-1.0.lib内嵌mongo-c-driver/src/libbson/build/Debug/mongo-c-driver/src/libbson/build/Release/的副本。这似乎一切都是正确的。

下一步是构建mongo-c-driver。我运行CMake并尝试创建Visual Studio解决方案,但得到了错误:

Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 
Searching for sasl/sasl.h
  Not found (specify -DCMAKE_INCLUDE_PATH=C:/path/to/sasl/include for SASL support)
Searching for libsasl2
  Not found (specify -DCMAKE_LIBRARY_PATH=C:/path/to/sasl/lib for SASL support)
Current version (from VERSION_CURRENT file): 1.3.5
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:
BSON (ADVANCED)
    linked by target "mongoc_shared" in directory C:/Users/sdf/Downloads/mongo-c-driver-1.3.5
    linked by target "mongoc_static" in directory C:/Users/sdf/Downloads/mongo-c-driver-1.3.5

Configuring incomplete, errors occurred!
See also "C:/Users/sdf/Downloads/mongo-c-driver-1.3.5/build/CMakeFiles/CMakeOutput.log".

看起来变量BSON未设置为正确的值 - 它的值现在为BSON-NOTFOUND。有谁知道BSON的正确值是什么,以及它是否应该在编译libbson的过程中自动设置?

3 个答案:

答案 0 :(得分:1)

编译MongoDB c ++驱动程序的智能方法。使用 vcpkg

按照git上提到的说明下载vcpkg。 https://github.com/Microsoft/vcpkg

步骤1 C:\ vcpkg>。\ vcpkg搜索mongodb

步骤2 C:。\ vcpkg搜索mongodb安装mongo-cxx-driver

Stap 3 C:\ vcpkg>。\ vcpkg integration install

有用的链接。https://stackoverflow.com/a/46981525/8617780

答案 1 :(得分:0)

请仔细按照“在Windows上安装”说明进行操作:

https://api.mongodb.com/c/current/installing.html#building-windows

在构建libbson时,您似乎缺少设置CMAKE_INSTALL_PREFIX的部分,然后安装libbson并使用相同的CMAKE_INSTALL_PREFIX设置构建libmongoc。

答案 2 :(得分:0)

首先,你需要在libbson sln中构建INSTALL项目(在管理模式下运行vs,因为它需要像linux一样创建lib文件夹)

然后定义BSON_INCLUDE_DIR以包含INSTALL项目创建的文件夹和BSON到您构建的lib文件,例如cmake中的 C:/ Program Files / libbson / lib / bson-static-1.0.lib (此BSON命名有问题,应重命名为BSON_LIB)