2

我正在尝试构建 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

4

3 回答 3

1

编译MongoDB c++ driver.use vcpkg的聪明方法

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

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

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

步骤 3 C:\vcpkg>.\vcpkg 集成安装

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

于 2017-10-27T19:04:15.590 回答
0

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

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

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

于 2016-07-29T18:40:13.400 回答
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 )

于 2017-02-16T08:30:04.357 回答