Java JNI linking multiple libraries

坚强是说给别人听的谎言 提交于 2019-12-25 08:59:12

问题


I have written some code to load the shared object in Java. Here's the sample code:

public class helloworld
{
        static
        {
               System.loadLibrary("calcJava");
        }
        public static void main(String [] args)
        {
                System.out.println("Hello");
        }
}

Shared object "calcJava" is further dependent on another shared object. libMath.so

When I attempt to run this, it always gives me unsatisfiedlinkerror with undefined symbol error from dependent .so (libMath.so).

Before executing the java program, here's what I am doing:

1) Set LD_LIBRARY_PATH to both the .so

2) Set CLASSPATH to the jar file

3) Run the java program with "java helloworld -Djava.library.path=/path/to/shared/object1:/path/to/shared/object2

Can anyone please explain why am I getting UnsatisfiedLinkError?

Here's the stacktrace

Exception in thread "main" java.lang.UnsatisfiedLinkError: /path/to/libcalcJava.so: /path/to/libcalcJava.so: undefined symbol: _xxx_xxx_Xxx_xx at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1938) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1122) at helloworld.(helloworld.java:6)

Thanks

来源:https://stackoverflow.com/questions/36307455/java-jni-linking-multiple-libraries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!