0

我正在尝试为 c++ 编译 mongodb 驱动程序并按照 url 中给出的说明进行操作:Mongocxx

我收到以下错误:

-- The CXX compiler identification is GNU 4.8.5
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking for module 'libbson-1.0>=1.5.0'
-- 

CMake Error at /usr/share/cmake3/Modules/FindPkgConfig.cmake:424 (message):
A required package was not found
Call Stack (most recent call first):
  /usr/share/cmake3/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
 cmake/FindLibBSON.cmake:33 (pkg_check_modules)
 src/bsoncxx/CMakeLists.txt:67 (find_package)


-- Configuring incomplete, errors occurred!
    See also "/data/2/nirmal/mongo_cpp/mongo-cxx-
    driver/build/CMakeFiles/CMakeOutput.log".

我检查了 libbson 已经安装在 /usr/local/bin 中。无法找出根本原因。请协助。

4

1 回答 1

2

如果您正在构建版本 3.1.X 或 3.0.x,则必须指定 libmongoc(mongodb c 驱动程序)安装的 libbson。

“构建 mongocxx 版本 3.1.x 和 3.0.x 的用户应使用 cmake 的 -DLIBMONGOC_DIR 和 -DLIBBSON_DIR 选项指定 libmongoc 安装目录。参见以下示例,假设 libmongoc 和 libbson 都安装到 /your/cdriver/字首:”

如果您在 linux 系统上构建,请尝试以下操作:

cmake -DCMAKE_BUILD_TYPE=发布 -DCMAKE_INSTALL_PREFIX=/usr/local .. -DBSONCXX_POLY_USE_MNMLSTC=1 -DLIBMONGOC_DIR=/usr -DLIBBSON_DIR=/usr/lib64

更详细的信息可以参考https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/

于 2017-07-20T14:01:49.453 回答