If your library path error is in the linker, during compile, you need to add the path to the library into the variable $LD_LIBRARY_PATH. If the library error is when you actually run the compiled program then you need to add the library path to /etc/ld.so.conf and run ldconfig to rebuild the library search path cache.

The purpose of the LD_LIBRARY_PATH environment variable is to instruct thelinker to consider additional directories when searching for libraries. Itsvalid use case is the test of alternative library versions installed innon-standard locations. In contrast to that, globally setting theLD_LIBRARY_PATH (e.g. in the profile of a user) is harmful because there isno setting that fits every program. The directories in the LD_LIBRARY_PATHenvironment variable are considered before the default ones and the onesspecified in the binary executable. Thus, a - say - systemcommand that is supposed to use a system library easily gets linked at runtimewith an API incompatible version. Also, having a program that relies on acertain LD_LIBRARY_PATH setting creates the maintenance burden to alwaysaccurately document that setting and distribute that documentation with thebinary. Instead, to avoid these issues, the additional directories (if any)that should be searched by the runtime linker should be specified via linkeroptions (e.g. -rpath or -R) at build-time. This results in thosedirectories being written to an ELF attribute that is considered by the runtimelinker (i.e. the runpath).




How To Check Ld Library Path In Solaris