I made an application (an executable) calling some dylib successfully, However, the dylib files and the executable are in different directory. I added the directory contains
You need to set the DYLD_LIBRARY_PATH environment variable.
From the dyld man page:
This is a colon separated list of directories that contain libraries. The dynamic linker
searches these directories before it searches the default locations for libraries. It allows
you to test new versions of existing libraries.
For each library that a program uses, the dynamic linker looks for it in each directory in
DYLD_LIBRARY_PATH in turn. If it still can't find the library, it then searches DYLD_FALL-
BACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH in turn.