Failed to create libcouchbase instance: Failed to open shared object

I am helping to evaluate the Couchbase C++ SDK for my company, and I am writing some test code to do so. At first things went well, where I was installing onto a development machine where I had the root access needed to install the couchbase packages via yum.
However, now I am trying to run executables on our test machines where root access is much more limited. I am seeing this error, and not sure what it is telling me:
$ ./a.out
Failed to create libcouchbase instance: Failed to open shared object
The same exact executable works on the development machine.
I'm pretty sure that the answer is related to me copying the /usr/lib/libcouchbase* libraries from the dev machine to my home directory on the test machine, and then setting LD_LIBRARY_PATH to be able to find them there. I'm hoping that there isn't anything more complex happening, like somehow the compiled executables can never be run on any other machine...
While we play more with this, I thought that this forum might be able to help me figure out how to track down the exact meaning of this error message, and whether this could ever happen in our production environment (where we would have installed the libraries into the normal /usr/lib/* location).

1 Answer

« Back to question.

Libcouchbase tries to load a shared object containing the plugin for the "io operations" dynamically during initialization. If you don't link you application with a special linker path, the runtime linker will look in /usr/lib for the libcouchbase_* libraries. You may use LD_LIBRARY_PATH to have the linker to look elsewhere, or you can add a special path to your binary by using the -rpath option to the linker (some linker picks up the LD_RUN_PATH environment variable and adds that to the binary during linking as well)