3

I am trying to use mongodb for the first time in c++. I just installed the latest version on Ubuntu and also installed the lastest v2.0 c++ driver code. It compiled just fine using scons. In the c++ file the below is my include.

#include <client/dbclient.h>

So..I am assuming I have to make a ref to a boost library but I don't know how to do it.

make all 
Building target: rtb
Invoking: GCC C++ Linker
g++ -L/usr/local/include/ -L/home/boost -L/home/cpp/mongo-cxx-driver-v2.0/mongo -lfcgi++ -o"rtb"  ./src/rtb.o   
./src/rtb.o: In function `__static_initialization_and_destruction_0':
/home/boost/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/boost/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/boost/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make: *** [rtb] Error 1
SethO
  • 2,703
  • 5
  • 28
  • 38

1 Answers1

4

Add -lboost_system to your link line.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • g++ -L/usr/local/include/ -L/home/boost -L/home/cpp/mongo-cxx-driver-v2.0/mongo -lfcgi++ -lboost_system -o"rtb" ./src/rtb.o I still get the same error –  Jan 15 '12 at 17:50
  • Well that doesn't make a whole lot of sense to me...perhaps try running `objdump -x` against your copy of libboost_system and seeing if the symbols you are missing are indeed in there. Next, try running `strace` on your `make` link step to see if it is indeed opening the same file you objdump'd. – John Zwinck Jan 15 '12 at 20:03
  • 1
    Try putting ./src/rtb.o before -lboost_system. – avl_sweden Nov 11 '12 at 11:51