MongoDB C++ 驱动程序 - 错误:尚未声明"mongo::client"
mongodb c++ driver- error: "mongo::client" has not been declared
编译并成功安装 mongo-cxx-driver (mongo db c++ driver - 26Compat - 所有测试正常通过(。 目录/usr,所以/usrmongo/client/dbclient.h 存在。
-运行CMD:
g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_system -lboost_regex -lboost_filesystem -lboost_program_options -o 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;
}
结果 - 错误:
tutorial.cpp: In function ‘int main()’:
tutorial.cpp:11:12: error: ‘mongo::client’ has not been declared
有什么提示吗?
不确定这是否有帮助,但是在使用 apt-get 安装 mongo-dev 包后,我遇到了类似的错误。这不应该在 mongo 2.6 之后完成;它仅适用于 MONGO 2.4 或其他东西。它最终损坏了我的 2.6,所以我不得不清理所有内容,重新安装 mongo,然后根据他们的说明从 github 存储库 https://github.com/mongodb/mongo-cxx-driver 构建 mongo-cxx 驱动程序。
之后 eclipse 仍然为教程提供了错误,但奇怪的是它确实构建了这个东西。我不得不在那里清理调试和发布,最终只得到一个警告,因为包含被搞砸了。所以最后我只是废弃了 eclipse 项目,将教程文件复制到一个新项目中,现在它构建干净。
相关文章:
- #ifdef和未声明的标识符
- 未声明的标识符编译暗黑破坏神 2 程序"muleview"
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- Google protobuf 时间戳未声明标识符,在 Windows 上具有C++
- 在气泡排序程序中未声明错误功能
- 我在范围内未声明的错误类有问题
- 使用未声明的标识符"sqrt"?
- 我包含了<winuser.h>,但编译器在MonitorFromWindow上抛出"未声明"
- 对类 (C++) 中的私有变量使用未声明的标识符
- 我的代码中有错误,未声明的标识符
- 未定义的标识符/未声明
- 错误:在 C++ 'std'使用未声明的标识符
- 在编译器之前检测未声明的标识符
- 使用未声明的标识符'temp'
- 使用未声明的标识符"yylex"和"yyin"?
- 使用"class"关键字,后跟未声明的标识符
- 未声明的标识符错误,但变量定义正确 (?)
- C2065 'cout':未声明的标识符
- 在此范围内未声明错误"Clreol"
- C++模板模板参数中未声明的标识符