0

I am trying to run the mongodb c++ driver tutorial, but I get into trouble

g++ -std=c++11 -Wall -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system -O2 -I../../../mongo-client-install/include -c main.cpp -o obj/Release/main.o

this gives me an error

/usr/bin/ld: obj/Release/main.o||undefined reference to symbol _ZN5boost6system15system_categoryEv'|

I am using c++ driver 26compat and boost 1.55 on ubuntu with gcc 4.8

Some googling led me to

Why does GNU ld resolve symbols differently when linking executables vs shared objects?

but using --[no-]allow-shlib-undefined did not really help.

Any ideas?

Community
  • 1
  • 1
Mike
  • 3,775
  • 8
  • 39
  • 79
  • Are you sure that this error message corresponds to this command line? There is no main.o in either libmongoclient or other libraries. So, where does it come from? – Henry Hu Apr 21 '14 at 22:23
  • sorry about that. I have updated the command. Any idea? – Mike Apr 22 '14 at 17:17
  • This is the code that compile main.cpp into main.o, but your error message comes from the linker, so there must be another command which links main.o with other libraries to produce executable. My guess here is that you did not specify -lboost_system in the linker command. – Henry Hu Apr 22 '14 at 21:35
  • Yep indeed. I did not add the linker specification. cheers. – Mike May 01 '14 at 09:17

0 Answers0