Mongo Tutorial Not working On Ubuntu Server 12.04 with G++ 4.8
I'm having a problem compiling the Mongo tutorial code with my default g++ compiler version 4.8; it compiles just fine running
g++-4.6 tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_
But just running using g++ gives:
chrisd@romeo:~$ sudo apt-get install mongodb-dev libmongo-client-dev libboost-doc libboost-all-dev fop
[sudo] password for chrisd:
chrisd@romeo:~$ g++-4.6 tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_
chrisd@romeo:~$ g++ tutorial.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_
`.text.
`.text.
collect2: error: ld returned 1 exit status
I'm using:
g++ (Ubuntu 4.8.1-2ubuntu1~
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
After installing mongo with:
sudo apt-get install mongodb-dev libmongo-client-dev libboost-doc libboost-all-dev fop
Doing a dpkg list shows:
chrisd@romeo:~$ dpkg --list | grep mongo
ii libmongo-client-dev 0.1.4-3 Development files for the alternate C driver for MongoDB
ii libmongo-client0 0.1.4-3 Alternate C driver for the MongoDB document-oriented datastore
ii mongodb-clients 1:2.0.4-1ubuntu2.1 object/
ii mongodb-dev 1:2.0.4-1ubuntu2.1 object/
ii mongodb-server 1:2.0.4-1ubuntu2.1 object/
The content of the tutorial file is:
chrisd@romeo:~$ cat tutorial.cpp
#include <cstdlib>
#include <iostream>
#include "mongo/
void run() {
mongo:
c.connect(
}
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;
}
Any help much appreciated. Thanks in advance
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Ubuntu gcc-4.8 Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Christopher Dawes
- Solved:
- Last query:
- Last reply: