Java JNI:指定依赖共享库的路径

时间:2014-09-30 04:12:37

标签: java java-native-interface

我构建了一个JNI库libmyjni.dylib,它与libthirdparty.dylib链接。在启动我的Java应用程序时,我设置了-Djava.library.path=/path/to/native/libs,但该路径未用于加载libthirdparty.dylib。 Java始终在libthirdparty.dylib文件夹下查找<project_root>/lib。我设置了什么参数,以便在与libthirdparty.dylib相同的路径中查找java.library.path

如果我没有将libthirdparty.dylib放在<project_root>/lib下,这是我得到的错误。我也尝试在int中使用/etc/ld.so.conf的路径创建libthirdparty.dylib,但这也无济于事。

java.lang.UnsatisfiedLinkError: <java_library_path>/libmyjni.dylib: dlopen(<java_library_path>/libmyjni.dylib, 1): Library not loaded: lib/libthirdparty.dylib
  Referenced from: <java_library_path>/libmyjni.dylib
  Reason: image not found

1 个答案:

答案 0 :(得分:0)

var data = GetRecord(0);//First Record var data = GetRecord(1);//Second record var data = GetRecord(9);// 10th record 仅适用于JNI库,不适用于它们依赖的库。系统路径用于那些与系统相关的路径:设置class ChartContainer extends React.Component { constructor(props) { super(props); this.echarts_react = null; this.onEvents = { click: this.handleClick() }; } handleClick = e => console.log("e>>>>>>>>>", e) render() { return ( <ReactEcharts ref={e => { this.echarts_react = e; }} option={this.props.chartOption} style={{ height: '100%', width: '100%' }} onEvents={this.onEvents} /> ); } } java.library.pathPATH(分别在Windows,Linux或OSX上)

基于@ user207421和@CHmoonKa对问题的评论。