I have some code that uses some shared libraries (c code on gcc). When compiling I have to explicitly define the include and library directories using -I and -L, since they aren't in the standard places. When I try to run the code, I get the following error:
./sync_test: error while loading shared libraries: libsync.so: cannot open shared object file: No such file or directory
in your .bashrc otherwise, it'll only be available to bash and not any programs you start.
-R/path/to/library/ flag when you're linking, it'll make the program look in that directory and you won't need to set any environment variables.
EDIT: Looks like
-R is Solaris only, and you're on Linux.
An alternate way would be to add the path to
/etc/ld.so.conf and run
ldconfig. Note that this is a global change that will apply to all dynamically linked binaries.