MongoDB c++旧驱动1.1.2不工作-与VS2013, win10, boost-1_62编译
MongoDB c++ legacy driver 1.1.2 not working - Compiled with VS2013, Win 10, boost-1_62
驱动编译成功,没有问题。我编写了一个简单的程序来测试驱动程序。基本代码如下:
static std::vector<mongo::HostAndPort> hosts = { mongo::HostAndPort("xxxxxxxx-a0.mlab.com:xxxxx"), mongo::HostAndPort("xxxxxxxx-a1.mlab.com:xxxxx") };
static mongo::DBClientReplicaSet con("rs-xxxxxxxx", hosts, 0);
std::string errmsg;
mongo::client::initialize();
con.connect();
con.auth("dbname", "userid", "password", errmsg);
我编译代码没有问题。exe无法在bug模式下启动,给出错误0xc000a200。我根本无法调试。在释放模式下,它在启动时就停止了。我注意到控制台有一个boost警告:
Assertion failed: px != 0, file C:Boostincludeboost-1_62boost/smart_ptr/scoped_ptr.hpp, line 105
弹出错误提示:
MongoDB c++ Legacy Driver Error
我可以选择调试,这里是程序停止的地方- replica_set_monitor.cpp的最后一行:
void ReplicaSetMonitor::createIfNeeded(const string& name, const set<HostAndPort>& servers) {
LOG(3) << "ReplicaSetMonitor::createIfNeeded " << name;
boost::lock_guard<boost::mutex> lk(setsLock);
ReplicaSetMonitorPtr& m = sets[name];
if (!m)
m = boost::make_shared<ReplicaSetMonitor>(name, servers);
// Don't need to hold the lifetime lock for safeGo as
// 1) we assume the monitor is created as the contract of this class is such that initialize()
// must have been called.
// 2) replicaSetMonitorWatcher synchronizes safeGo internally using the _monitorMutex
replicaSetMonitorWatcher->safeGo();
}
请帮忙!非常感谢!
您需要在构建任何驱动程序对象或BSON之前调用mongo::client::initialize
。将调用移动到上面声明DBClientReplicaSet对象的mongo::client::initialize
。
相关文章:
- 无法从 Win10 中的 IDirectDraw7 查询 IDirect3D7
- xtr1common中的错误,尝试使用VS2019构建原始VS2013 C++项目时type_traits
- DirectShow 在 Win7/Win10 上失败并显示黑框和0x80070005
- C++构建增强 1.57.0 VS2013 x64 本机工具命令提示符
- Build Boost Regex for Windows VS2013
- 在Win10上使用带有Qt5的OpenCV3.0,调试断言失败
- win10 尝试在我运行它时寻找问题的解决方案
- 在VS2013中使用devenv (C++)传递命令行参数argv
- VS Express 2015 Win10 应用程序 - ifstream 无法打开文件
- 将VS2013 更新为VS2019会导致左值错误,想知道原因
- 从 VS2013 到 VS2017 std::async 不会启动新线程
- 在 Linux 上打开() 与 O_RDWR |O_CREAT |如果文件位于 Win10 PC 的桑巴共享上,O_EX
- VS2013在构建容器应用程序时无法识别OCX控制的附加方法
- 如何在win10上调试崩溃
- 我可以将Visual Studio 2015头文件编译成dll并在VS2013中使用它吗?
- 代码块错误: "File cannot be saved" -Win10 64 位-
- 为什么添加constexpr使VS2013拒绝这一点
- 在 Win10 上编译 V8 引擎时LNK1181错误
- <ratio> <memory> 从 VS2013 升级到 VS2017 时和之后出错
- MongoDB c++旧驱动1.1.2不工作-与VS2013, win10, boost-1_62编译