0
我一直在使用爲什麼mongo C++驅動程序給我編譯錯誤?
sudo scons --full install
,並具有以下示例源文件
#include <cstdlib>
#include <iostream>
#include <mongo/client/dbclient.h>
void run() {
mongo::DBClientConnection c;
c.connect("localhost");
}
int main() {
try {
run();
std::cout << "connected ok" << std::endl;
} catch(const mongo::DBException &e) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
當我運行
g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem
-lboost_program_options -lboost_system -o tutorial
我給出的錯誤
In file included from /usr/local/include/mongo/util/net/hostandport.h:21:0,
from /usr/local/include/mongo/util/net/message.h:24,
from /usr/local/include/mongo/client/dbclientinterface.h:30,
from /usr/local/include/mongo/client/connpool.h:23,
from /usr/local/include/mongo/client/dbclient.h:32,
from tutorial.cpp:3:
/usr/local/include/mongo/db/server_options.h:34:51: fatal error:
mongo/util/options_parser/environment.h: No such file or directory
compilation terminated.
安裝蒙戈直接從GitHub
我看着/ usr/local/include/mongo/util,但options_parser文件夾不在那裏。