简体   繁体   中英

Can't use static lib of mongo-cxx-driver on Linux

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 ?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM