1

So I follow the official tutorial for the installation : https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/

Neverless, I can't use the produced libraries as static.

So I managed to compile the C version of the driver as described, I've enabled the flag --enable-static=yes with the ./configure before doing make && sudo make install and I got the libmongoc-1.0.a and the libbson-1.0.a which are static. So this far, everything it's alright.

Then I have done the cxx version of the driver, except that there is no configuration file as in the C version. So I've juste done a

cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DCMAKE_INSTALL_PREFIX=/usr/local

from the build folder, followed by a make && sudo make install

So I got the libmongocxx.a and the libbsoncxx.a, but when I try to compile with them, I can't run the binary because I got the following error : error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory

So I understand that is because there is some symbols missing and then I need to use the shared library to run the binary but I don't want this to happend, I want the symbols within the binary that I can run it without any LD_PRELOAD.

Any suggestions ?

Tazrof
  • 11
  • 2
  • You haven't mentioned how you compiled your application. Please post a [SSCCE](http://sscce.org) so we can try to replicate your issue. In this case, please include the exact command lines (or a shell script) and output as well. – xdg Nov 11 '16 at 18:45

2 Answers2

1

I had the same issue in an Ubuntu 16.04 and I run a apt-get update & apt-get upgrade and the problem was solved.

It seems that there were some update to the compiler and some libraries that prevent some test from reaching the shared libraries.

0

I have a similar question, and solved, now I compiled and run my binary with static libs successfully.

I write my build script using newlisp, but the static link options are very helpful, I paste it here.

c++  /to/your/path/site/code/back_end/builder/object/files1.cc.o ... /to/your/path/site/code/back_end/builder/object/files10.cc.o -o bin/site -static-libgcc -static-libstdc++ -L/usr/lib -lpthread -l:libmongocxx.a -l:libbsoncxx.a -l:libmongoc-1.0.a -l:libbson-1.0.a -lrt -lssl -lcrypto -lsasl2 -l:libboost_log.a -l:libboost_log_setup.a -l:libboost_system.a -l:libboost_thread.a -l:libboost_filesystem.a -lcppcms -lbooster -lcurl -ljsoncpp
Community
  • 1
  • 1
Dean Chen
  • 3,800
  • 8
  • 45
  • 70