Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Cxx driver cannot find dependencies

I successfully compiled and installed the mongo cxx driver from the official manual. Compiling the example projects/mongocxx/cmake/shared works as well. So I guess I have a correctly installed mongo cxx driver.

Now I wrote a very simple main.cpp, including only mongocxx/instance.hpp and trying to create a mongocxx::instance only. It compiles but when run it gives this error:

error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory

Then I tried to track down this error with the official example mentioned above. When I comment out line 39 and 40 this example gives the same error message.

Can anyone help and explain this behaviour? Why is libbsoncxx needed when I do not use it and why is it not found? It is definitely there, in the same folder like libmongocxx

Thanks for any help!

Please provide your main.cpp, and the terminal output showing compilation, how you invoked the program, and the complete error text.

step by step instruction how to reproduce the error

  1. the mongocxx sources are extracted to /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0
  2. the install folder is inside this: /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/install
  3. change example file /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/examples/projects/mongocxx/hello_mongo.cxx into something very simple:
#include <mongocxx/instance.hpp>
int main(int, char* [])
{
    mongocxx::instance inst;
    return 0;
}
  1. go to /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/examples/projects/mongocxx/cmake/shared/build
  2. set path to install folder: export CMAKE_PREFIX_PATH=/home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/install
  3. cmake ..

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/examples/projects/mongocxx/cmake/shared/build
  1. make
Scanning dependencies of target hello_mongocxx
[ 50%] Building CXX object CMakeFiles/hello_mongocxx.dir/home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/examples/projects/mongocxx/hello_mongocxx.cpp.o
[100%] Linking CXX executable hello_mongocxx
[100%] Built target hello_mongocxx
  1. start the executable: ./hello_mongocxx
./hello_mongocxx: error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory
  1. readelf -d hello_mongo.cxx
Dynamic section at offset 0x2d98 contains 29 entries:
  Tag       Typ                          Name/Wert
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libmongocxx.so._noabi]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libc.so.6]
 0x000000000000001d (RUNPATH)            Bibliothek runpath: [/home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/install/lib]
 0x000000000000000c (INIT)               0x1000
 0x000000000000000d (FINI)               0x1268
 0x0000000000000019 (INIT_ARRAY)         0x3d88
 0x000000000000001b (INIT_ARRAYSZ)       8 (Bytes)
 0x000000000000001a (FINI_ARRAY)         0x3d90
 0x000000000000001c (FINI_ARRAYSZ)       8 (Bytes)
 0x000000006ffffef5 (GNU_HASH)           0x3a0
 0x0000000000000005 (STRTAB)             0x5b8
 0x0000000000000006 (SYMTAB)             0x3f0
 0x000000000000000a (STRSZ)              395 (Bytes)
 0x000000000000000b (SYMENT)             24 (Bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x3fa8
 0x0000000000000002 (PLTRELSZ)           72 (Bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x860
 0x0000000000000007 (RELA)               0x7a0
 0x0000000000000008 (RELASZ)             192 (Bytes)
 0x0000000000000009 (RELAENT)            24 (Bytes)
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
 0x000000006ffffffe (VERNEED)            0x770
 0x000000006fffffff (VERNEEDNUM)         1
 0x000000006ffffff0 (VERSYM)             0x744
 0x000000006ffffff9 (RELACOUNT)          3
 0x0000000000000000 (NULL)               0x0
  1. readelf -d /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/install/lib/libmongocxx.so._noabi
Dynamic section at offset 0x8ecc8 contains 31 entries:
  Tag       Typ                          Name/Wert
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libmongoc-1.0.so.0]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libbsoncxx.so._noabi]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libbson-1.0.so.0]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Gemeinsame Bibliothek [libc.so.6]
 0x000000000000000e (SONAME)             soname der Bibliothek: [libmongocxx.so._noabi]
 0x000000000000001d (RUNPATH)            Bibliothek runpath: [/home/gernot/Development/3rdparty/mongo-c-driver/install/lib]
 0x000000000000000c (INIT)               0x28000
 0x000000000000000d (FINI)               0x77218
 0x0000000000000019 (INIT_ARRAY)         0x8f768
 0x000000000000001b (INIT_ARRAYSZ)       312 (Bytes)
 0x000000000000001a (FINI_ARRAY)         0x8f8a0
 0x000000000000001c (FINI_ARRAYSZ)       8 (Bytes)
 0x000000006ffffef5 (GNU_HASH)           0x2f0
 0x0000000000000005 (STRTAB)             0xb268
 0x0000000000000006 (SYMTAB)             0x27a8
 0x000000000000000a (STRSZ)              91028 (Bytes)
 0x000000000000000b (SYMENT)             24 (Bytes)
 0x0000000000000003 (PLTGOT)             0x90000
 0x0000000000000002 (PLTRELSZ)           18504 (Bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x23488
 0x0000000000000007 (RELA)               0x222a0
 0x0000000000000008 (RELASZ)             4584 (Bytes)
 0x0000000000000009 (RELAENT)            24 (Bytes)
 0x000000006ffffffe (VERNEED)            0x22190
 0x000000006fffffff (VERNEEDNUM)         3
 0x000000006ffffff0 (VERSYM)             0x215fc
 0x000000006ffffff9 (RELACOUNT)          82
 0x0000000000000000 (NULL)               0x0

That is strange. What is the output of ldd ./hello_mongocxx and ls -l /home/gernot/Development/3rdparty/mongo-cxx-driver/3.5.0/install/lib /home/gernot/Development/3rdparty/mongo-c-driver/install/lib?