【发布时间】:2016-11-17 16:02:07
【问题描述】:
我正在尝试使用 Visual Studio 构建以下示例 C++ 代码:
#include <iostream>
#include <bsoncxx/builder/stream/document.hpp>
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
int main(int, char**) {
mongocxx::instance inst{};
mongocxx::client conn{mongocxx::uri{}};
bsoncxx::builder::stream::document document{};
auto collection = conn["testdb"]["testcollection"];
document << "hello" << "world";
collection.insert_one(document.view());
auto cursor = collection.find({});
for (auto&& doc : cursor) {
std::cout << bsoncxx::to_json(doc) << std::endl;
}
}
我已经根据这个构建了驱动程序: https://github.com/mongodb/mongo-cxx-driver/blob/master/appveyor.yml
系统信息: -Win10 -Visual Studio 社区 2015 更新 3 - 使用 Boost 1.60.0 64 位 - 使用 CMake 3.7.0 - 使用 Git 2.10.2
另外,我在项目中添加了以下包含库: -bsoncxx -mongocxx -libmongoc -利布森 -促进 以及以下链接器库: - 提升 64 位库 -mongo 驱动程序库
如果有人能告诉我我的构建出了什么问题,将不胜感激。
【问题讨论】:
-
您正在构建哪个版本的 mongocxx?
-
github的最新版本,我认为是3.0.3版。
-
这看起来像是一个 MSVC 问题。例如,请参阅 this post 或 this Google search。一旦你得到正确的比率和计时构建,我怀疑 mongocxx 位会起作用。
-
太棒了,第一个链接帮助解决了这个问题,谢谢!