【问题标题】:mongo-c-driver cannot find libbsonmongo-c-driver 找不到 libbson
【发布时间】:2016-07-28 19:16:04
【问题描述】:

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

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

下一步是构建 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 的过程中自动设置?

【问题讨论】:

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


    【解决方案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

    【讨论】:

    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    • 你是对的,我已经编辑了我的答案。 @Jeff Zeitlin
    【解决方案2】:

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

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

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

    【讨论】:

    • 您好,我的回答能解决您的问题还是您需要更多信息?
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-01-22
      • 1970-01-01
      • 2016-07-09
      • 1970-01-01
      • 2021-10-11
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      相关资源
      最近更新 更多