原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: [已解决]MongoDB C++ /usr/local/include/boost/smart_ptr/scoped_ptr.hpp:97: T* boost::scoped_ptr::operator->() const [with T = mongo::AtomicWord]: Assertion `px != 0′ failed. Aborted (core dumped)
本文链接地址: [已解决]MongoDB C++ /usr/local/include/boost/smart_ptr/scoped_ptr.hpp:97: T* boost::scoped_ptr
进行数据操作时报错:
quant_ctp_XTrader: /usr/local/include/boost/smart_ptr/scoped_ptr.hpp:97: T* boost::scoped_ptr<T>::operator->() const [with T = mongo::AtomicWord<unsigned int>]: Assertion `px != 0' failed.
Aborted (core dumped)
解决办法:
在连接之前,加上:
mongo::client::initialize();
附上一段MongoDB的C++连接代码tutorial.cpp:
#include <cstdlib> #include <iostream> #include <mongo/client/dbclient.h> // for the driver void run() { mongo::DBClientConnection c; c.connect("localhost"); mongo::DBClientConnection c1; c1.connect("localhost"); } int main() { mongo::client::initialize(); try { run(); std::cout << "connected ok" << std::endl; } catch( const mongo::DBException &e ) { std::cout << "caught " << e.what() << std::endl; } return EXIT_SUCCESS; }
编译脚本:
g++ -std=c++0x tutorial.cpp -pthread -lmongoclient -lboost_thread -lboost_system -lboost_regex -o tutorial
原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: [已解决]MongoDB C++ /usr/local/include/boost/smart_ptr/scoped_ptr.hpp:97: T* boost::scoped_ptr::operator->() const [with T = mongo::AtomicWord]: Assertion `px != 0′ failed. Aborted (core dumped)
本文链接地址: [已解决]MongoDB C++ /usr/local/include/boost/smart_ptr/scoped_ptr.hpp:97: T* boost::scoped_ptr
文章的脚注信息由WordPress的wp-posturl插件自动生成