mongodb c++;驱动程序-错误:";mongo::客户机“;尚未申报 编译成功安装MunGCXX驱动程序(蒙戈DB C++驱动程序-26COMPAT-所有测试通过OK)。目录/usr,so/usrmongo/client/dbclient.h存在

mongodb c++;驱动程序-错误:";mongo::客户机“;尚未申报 编译成功安装MunGCXX驱动程序(蒙戈DB C++驱动程序-26COMPAT-所有测试通过OK)。目录/usr,so/usrmongo/client/dbclient.h存在,c++,mongodb,C++,Mongodb,-正在运行cmd: g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_system -lboost_regex -lboost_filesystem -lboost_program_options -o tutorial -文件tutorial.cpp #include <cstdlib> #include <iostream> #include "mongo/client/dbclien

-正在运行cmd:

g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_system -lboost_regex -lboost_filesystem -lboost_program_options -o tutorial
-文件tutorial.cpp

#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h" // for the driver

void run() {
  mongo::DBClientConnection c;
  c.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;
}

有什么提示吗?

不确定这是否有帮助,但在使用apt get安装mongo开发包后,我遇到了类似的错误。这不应在mongo 2.6之后进行;它只适用于Mongo2.4或其他版本。它最终破坏了我的2.6,因此我必须清理一切,重新安装mongo,然后根据github repo的说明从github中构建mongo cxx驱动程序

后来eclipse仍然为教程提供了一个错误,但奇怪的是它确实构建了这个东西。我不得不在那里清理调试和发布,结果只有一个警告,因为包含的内容被弄乱了。所以最后我放弃了eclipse项目,将教程文件复制到一个新项目中,现在它构建得很干净

tutorial.cpp: In function ‘int main()’:
tutorial.cpp:11:12: error: ‘mongo::client’ has not been declared