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?

I just run into the same issue

❯ ldd ./src/pilot/PMSPilot
        linux-vdso.so.1 (0x00007ffff2f47000)
        libdocopt.so.0 => /mnt/f/OpenSource_Projects/PMS/build/_deps/docopt-build/libdocopt.so.0 (0x00007fab53d24000)
        libDBHandle.so => /mnt/f/OpenSource_Projects/PMS/build/src/db/libDBHandle.so (0x00007fab53cb6000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fab53c84000)
        libmongocxx.so._noabi => /mnt/f/OpenSource_Projects/mongo-cxx-driver-install/lib/libmongocxx.so._noabi (0x00007fab53bd7000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fab539e0000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fab539c0000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fab537c0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fab53fed000)
        libmongoc-1.0.so.0 => /mnt/f/OpenSource_Projects/mongo-c-driver-install/lib/libmongoc-1.0.so.0 (0x00007fab5370a000)
        libbsoncxx.so._noabi => not found
        libbson-1.0.so.0 => /mnt/f/OpenSource_Projects/mongo-c-driver-install/lib/libbson-1.0.so.0 (0x00007fab536c1000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fab53572000)
        libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007fab534d0000)
        libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fab531f0000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fab531e0000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fab531c0000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fab531a0000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007fab52fb0000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fab52fa0000)
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007fab514d0000)

and

❯ ls -l /mnt/f/OpenSource_Projects/mongo-cxx-driver-install/lib
total 1140
drwxr-xr-x 1 vformato vformato   4096 Mar 17 11:48 cmake
lrwxrwxrwx 1 vformato vformato     20 Mar 17 11:48 libbsoncxx.so -> libbsoncxx.so._noabi
-rw-r--r-- 1 vformato vformato 222272 Mar 18 15:20 libbsoncxx.so.3.7.0-pre
lrwxrwxrwx 1 vformato vformato     23 Mar 17 11:48 libbsoncxx.so._noabi -> libbsoncxx.so.3.7.0-pre
lrwxrwxrwx 1 vformato vformato     21 Mar 17 11:48 libmongocxx.so -> libmongocxx.so._noabi
-rw-r--r-- 1 vformato vformato 938144 Mar 18 15:20 libmongocxx.so.3.7.0-pre
lrwxrwxrwx 1 vformato vformato     24 Mar 17 11:48 libmongocxx.so._noabi -> libmongocxx.so.3.7.0-pre
drwxr-xr-x 1 vformato vformato   4096 Mar 17 11:48 pkgconfig