原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: [已解决]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插件自动生成

微信扫一扫,打赏作者吧~![[整理][转载]win下网卡抓包发包库Npcap使用](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2023/08/demo_1-1024x711.jpg&w=280&h=210&zc=1)
![[转载]基础数据char,int,double,string是线程安全的吗?](http://www.jyguagua.com/wp-content/themes/begin/img/random/6.jpg)
![[已解决]nc命令报错 close: Bad file descriptor](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2022/03/Snipaste_2022-03-18_20-16-48.png&w=280&h=210&zc=1)
![[整理]用c++编写的RDTSC性能计时器](http://www.jyguagua.com/wp-content/themes/begin/timthumb.php?src=http://www.jyguagua.com/wp-content/uploads/2020/12/rdtsc-assembly-example.jpg&w=280&h=210&zc=1)