Just a quick note to myself:
In Linux, shared C object libraries (.so) are usually found in /usr/lib which is also in the default linker search path. A problem arises when compiling programs requiring shared libraries located in /usr/local/lib, the directory for non-system libraries.
The resulting binary can usually not be executed, since the shared object files are not found during runtime.
Common hacks are setting the LD_LIBRARY_PATH environment variable (linker search path) to include /usr/local/lib or editing /ect/ld.so.conf to include this path.
A more portable solution is to include /usr/local/lib in the run path of the binary file with the ld option -R.
When using g++ for linking, use the option -Wl,-rpath,/usr/local/lib. The resulting binary can now run without extra hacks.
More info.