我正在尝试关注this guide,我目前正处于第3步。
跑完后,
curl -OL https://github.com/mongodb/mongo-cxx-driver/archive/r3.0.1.tar.gz
tar -xzf r3.0.1.tar.gz
cd mongo-cxx-driver-r3.0.1/
我尝试执行Windows guide for mongoc中的类似命令:
如果我这样做
cmake -G "Visual Studio 14 2015 Win64" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/mongo-cxx-driver"
我收到错误
CMake Error at cmake/FindLibBSON.cmake:37 (message):
Don't know how to find libbson; please set LIBBSON_DIR to the prefix
directory with which libbson was configured.
Call Stack (most recent call first):
src/bsoncxx/CMakeLists.txt:67 (find_package)
所以在这里我尝试了不同的东西,比如添加libsson目录的路径:
cmake -G "Visual Studio 14 2015 Win64" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/mongo-cxx-driver" "-DLIBBSON_DIR=C:/mongo-c-driver/lib/pkgconfig/" "-DLIBMONGOC_DIR=C:/mongo-c-driver/lib/pkgconfig/" "-DBOOST_ROOT=C:/local/boost_1_62_0/"
这实际上有效,但是当我尝试用
构建时msbuild.exe ALL_BUILD.vcxproj
我收到错误:
C:\Users\Erik\Documents\mongo-cxx-driver-r3.0.1\src\bsoncxx\array\view.cpp(21): fatal error C1083: Cannot open include
file: 'bson.h': No such file or directory [C:\Users\Erik\Documents\mongocxx-driver-r3.0.1\src\bsoncxx\bsoncxx_static.v
cxproj]
此文件," bson.h"似乎存在于直率
中C:\mongo-c-driver\include\libbson-1.0
但我不确定为什么它找不到该文件或我如何能够这样做。
非常感谢您的任何意见。
答案 0 :(得分:4)
您没有正确设置include
和lib
。在您的情况下,它们应设置为CMAKE_INSTALL_PREFIX
。构建系统将根据需要自动将LIBBSON_DIR
和LIBMONGOC_DIR
添加到该基本路径。您可能会发现阅读有关信息的appveyor脚本:
swift
:https://github.com/mongodb/mongo-cxx-driver/blob/master/appveyor.yml#L25 view
和textView
:https://github.com/mongodb/mongo-cxx-driver/blob/master/appveyor.yml#L31 答案 1 :(得分:0)
2016年10月18日
此问题也适用于Mac OS X,也可能适用于其他Un * xes。
curl -OL https://github.com/mongodb/mongo-cxx-driver/archive/r3.0.2.tar.gz
build
目录,而是更改为根目录:cd mongo-cxx-driver-r3.0.2
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/mongodbDriverCpp -DLIBBSON_DIR=/opt/mongodbDriverCpp -DLIBMONGOC_DIR=/opt/mongodbDriverCpp -DCMAKE_CXX_STANDARD=14
make make install
/opt/mongodbDriverCpp
更改为您的正确目录):c++ --std=c++11 test.cpp -o run.test -I/opt/mongodbDriverCpp/include/bsoncxx/v_noabi -I /opt/mongodbDriverCpp/include/mongocxx/v_noabi/ -L /opt/mongodbDriverCpp/lib -l mongocxx -l bsoncxx
export LD_LIBRARY_PATH=/opt/mongodbDriverCpp/lib ./run.test