DYLD_LIBRARY_PATH Mac 开发问题 java.lang.UnsatisfiedLinkError

DYLD_LIBRARY_PATH 是 Mac 的环境变量。在项目中主要是在MAC OS X 系统中添加libXX.jnilib,以实现Java JNI。

如果不添加这个环境变量,Java 报错:java.lang.UnsatisfiedLinkError: no XX in java.library.path。

 

以下是Apple 的在线文档关于 DYLD_LIBRARY_PATH 说明。

DYLD_LIBRARY_PATH 
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 DYLD_FALLBACK_FRAMEWORK_PATH
BACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH in turn.

Use the -L option to otool (1) . to discover the frameworks and shared libraries that the exe-cutable executable
cutable is linked against.

可以在Java 中通过System 类察看属性 java.library.path :
System.getProperty("java.library.path");
可以发现,通过 DYLD_LIBRARY_PATH 加入的系统环境变量,出现在属性中。

当然,这只是在Mac OS X 系统中。
在Linux 系统中对应的环境变量是:LD_LIBRARY_PATH。
在Window 系统中对应的变量是:Path。(可能是)

你可能感兴趣的:(java,Path,each,library,frameworks,linker)