Re: Trying to get c++ driver working in ubuntu 12.4

152 views
Skip to first unread message

Jason Rassi

unread,
Oct 1, 2012, 11:06:41 AM10/1/12
to mongodb-user
There shouldn't be any issues with linking against Boost shared
libraries and the C++ driver. Could you post the linker command
you're running?

Note as an example (standalone C++ driver, Boost 1.48 from precise/
universe):

ubuntu@ubuntu:~$ cat c.cpp
#include "mongo/client/dbclient.h"
using namespace mongo;
int main() {
DBClientConnection c;
c.connect("localhost");
return 0;
}
ubuntu@ubuntu:~$ g++ -o c c.o -lmongoclient -lboost_thread -
lboost_filesystem -lboost_system
ubuntu@ubuntu:~$ ldd c
linux-vdso.so.1 => (0x00007fff69bd5000)
libboost_thread.so.1.48.0 => /usr/lib/libboost_thread.so.1.48.0
(0x00007fb742701000)
libboost_filesystem.so.1.48.0 => /usr/lib/libboost_filesystem.so.
1.48.0 (0x00007fb7424e2000)
libboost_system.so.1.48.0 => /usr/lib/libboost_system.so.1.48.0
(0x00007fb7422dd000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007fb741fdd000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb741ce3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007fb741acc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb74170f000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007fb7414f2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb742923000)

On Sep 29, 10:37 pm, Troy <troy.he...@hixxy.org> wrote:
> Hello,
>
> I have been trying all day to get the c++ driver working on ubuntu.
>
> Initially I tried using the driver in the repositories, but this failed
> because of name clashes caused by macros in the global namespace (assert).
>
> Next I tried compiling the latest driver at :
>
> http://downloads.mongodb.org/cxx-driver/mongodb-linux-x86_64-v2.2-lat...
>
> This compiled fine, except when linking to my project I get a lot of
> undefined reference errors for boost::system. So in my travels I've
> discovered that the driver only likes to link against static boost
> libraries.
>
> So I downloaded boost 1.51 and compiled it as static only to find that the
> cxx driver doesn't compile with boost 1.5+. So I downloaded boost 1.49 and
> compiled with the following options
>
> /b2 --link=static --threading=multi
>
> This compiled fine and installed, and the driver compiled and installed
> fine as well. The undefined reference errors when linking the driver to my
> project still persist!
>
> util.cpp:(.text.startup+0x23): undefined reference to
> `boost::system::generic_category()'
> util.cpp:(.text.startup+0x2f): undefined reference to
> `boost::system::generic_category()'
>
> So on ....
>
> I use boost in my current project, so -lboost_system is even included to no
> avail.
>
> Any ideas? What's the go with the nightmare cxx driver?! Why isn't there a
> shared library?
>
> Thanks.

Troy

unread,
Oct 2, 2012, 11:37:46 PM10/2/12
to mongod...@googlegroups.com
Discovered the problem, seems the boost libs need to be added the the linking command AFTER the -lmongoclient
Reply all
Reply to author
Forward
0 new messages