- mongo-cxx-driver (mongo db C++ 드라이버 - 26Compat - 모든 테스트가 통과되었습니다)가 성공적으로 컴파일 및 설치되었습니다. 디렉토리/usr이므로 /usrmongo/client/dbclient.h가 있습니다.mongodb C++ 드라이버 오류 : "mongo :: client"가 선언되지 않았습니다.
-running 명령 :
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;
}
결과 - 오류 :
tutorial.cpp: In function ‘int main()’:
tutorial.cpp:11:12: error: ‘mongo::client’ has not been declared
어떤 힌트?