0

I have a c++ program, Alpine3d, which runs fine when I invoke it from the command line. This program uses MongoCXX to output data to a MongoDB.

On one Ubuntu 18 PC, I can successfully run Alpine3d from R using the "system" command. However, on another Ubuntu 18 PC where Alpine3D runs correctly from the command line, trying to run Alpine3D from R throws the error:

alpine3d: symbol lookup error: /usr/local/lib/libmongocxx.so._noabi: undefined symbol: mongoc_transaction_opts_destroy

This library, /usr/local/lib/libmongocxx.so._noabi, exists. I suspected it could be MongoCXX being improperly installed, but after reinstalling I don't think so.

Based on this thread, Error while loading shared libraries: libbsoncxx.so._noabi: cannot open shared object file: No such file or directory, I've also played with the CMakeLists.txt to make sure the Mongo and BSON libraries are properly linked and it looks like they're picked up successfully.

Any ideas what to investigate? Happy to show off some code if anyone has ideas of where to start.

Thanks for any ideas!

[Update] In response to Ralf's comment:

The output of ldd $(which alpine3d) at the command line is:

$ ldd $(which alpine3d)
    linux-vdso.so.1 (0x00007ffc097aa000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f15a5675000)
    libbsoncxx.so._noabi => /usr/local/lib/libbsoncxx.so._noabi (0x00007f15a5458000)
    libmongocxx.so._noabi => /usr/local/lib/libmongocxx.so._noabi (0x00007f15a51cb000)
    libalpine3d.so.3 => /usr/local/lib/libalpine3d.so.3 (0x00007f15a4f39000)
    libmeteoio.so.2 => /usr/local/lib/libmeteoio.so.2 (0x00007f15a4b0f000)
    libsnowpack.so.3 => /usr/local/lib/libsnowpack.so.3 (0x00007f15a480a000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f15a4481000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f15a40e3000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15a3ecb000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f15a5c7f000)
    libbson-1.0.so.0 => /usr/local/lib/libbson-1.0.so.0 (0x00007f15a3c91000)
    libmongoc-1.0.so.0 => /usr/local/lib/libmongoc-1.0.so.0 (0x00007f15a3a06000)
    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f15a37d7000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f15a35b8000)
    libproj.so.12 => /usr/lib/x86_64-linux-gnu/libproj.so.12 (0x00007f15a334f000)
    liblapack.so.3 => /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f15a2ac9000)
    libblas.so.3 => /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007f15a286e000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f15a2666000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f15a244b000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f15a222e000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f15a202a000)
    libopenblas.so.0 => /usr/lib/x86_64-linux-gnu/libopenblas.so.0 (0x00007f159fd84000)
    libgfortran.so.4 => /usr/lib/x86_64-linux-gnu/libgfortran.so.4 (0x00007f159f9a5000)
    libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f159f765000)

Which shows the links to libmongocxx etc.

From R:

system("ldd $(which alpine3d)")
    linux-vdso.so.1 (0x00007ffe0d5f2000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1fa84e4000)
    libbsoncxx.so._noabi => /usr/local/lib/libbsoncxx.so._noabi (0x00007f1fa82c7000)
    libmongocxx.so._noabi => /usr/local/lib/libmongocxx.so._noabi (0x00007f1fa803a000)
    libalpine3d.so.3 => /usr/local/lib/libalpine3d.so.3 (0x00007f1fa7da8000)
    libmeteoio.so.2 => /usr/local/lib/libmeteoio.so.2 (0x00007f1fa797e000)
    libsnowpack.so.3 => /usr/local/lib/libsnowpack.so.3 (0x00007f1fa7679000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1fa72f0000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1fa6f52000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1fa6d3a000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f1fa8aee000)
    libbson-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libbson-1.0.so.0 (0x00007f1fa6b03000)
    libmongoc-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libmongoc-1.0.so.0 (0x00007f1fa6890000)
    libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f1fa6661000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1fa6442000)
    libproj.so.12 => /usr/lib/x86_64-linux-gnu/libproj.so.12 (0x00007f1fa61d9000)
    liblapack.so.3 => /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f1fa5953000)
    libblas.so.3 => /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007f1fa56f8000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1fa54f0000)
    libssl.so.1.1 => /usr/lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f1fa5263000)
    libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f1fa4d98000)
    libsnappy.so.1 => /usr/lib/x86_64-linux-gnu/libsnappy.so.1 (0x00007f1fa4b90000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1fa4973000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1fa4758000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1fa4554000)
    libopenblas.so.0 => /usr/lib/x86_64-linux-gnu/libopenblas.so.0 (0x00007f1fa22ae000)
    libgfortran.so.4 => /usr/lib/x86_64-linux-gnu/libgfortran.so.4 (0x00007f1fa1ecf000)
    libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f1fa1c8f000)

I can see now that the folders are different. Where does R get this variable from that is different? Thanks again!

Fishish
  • 165
  • 1
  • 10
  • 1
    What is the output of `ldd $(which alpine3d)` and `ldd /usr/local/lib/libmongocxx.so._noabi` both on the command line and from R using `system()`? – Ralf Stubner Sep 25 '19 at 15:12
  • On closer inspection, the values do seem to be different. – Fishish Sep 25 '19 at 16:57
  • Why do you have to versions of `libmongoc` and `libbson`installed? R's startup script changes the `LD_LIBRARY_PATH` variable to include `/usr/lib/x86_64-linux-gnu/`, c.f. `RHOME/etc/ldpaths`. This can lead to [strange problems](https://stackoverflow.com/q/49318776/8416610). Maybe try to prepend `/usr/local/lib` to `LD_LIBRARY_PATH`. – Ralf Stubner Sep 25 '19 at 17:22
  • Should I just have libmongoc and libbson installed to ```/usr/lib/x86_64-linux-gnu/``` not ```/usr/local/lib```? I don't think I need to install to the latter folder and this error may be a byproduct of fumbled attempts to get the mongocxx library installed. – Fishish Sep 25 '19 at 18:22
  • 2
    Where the libraries in `/usr/lib/x86_64-linux-gnu` installed via the package manager? In that case I would (try to) remove the package(s). If not, I would remove the libraries from these directories, since I use `/usr/lib/x86_64-linux-gnu` only for things installed via the package manager. – Ralf Stubner Sep 25 '19 at 21:04

1 Answers1

2

Thanks to Ralf's comments, I got this figured out. I must've installed libmongoc from both the command line and by building from source code. To uninstall the version in /usr/lib/x86_64-linux-gnu I simply used the command line:

sudo apt-get remove libmongoc-1.0-0

Fishish
  • 165
  • 1
  • 10