我有一个需要加载本机代码库的 Java 程序(通过带有 SWIG 的 JNI),但是当我尝试运行它时,出现如下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/local/lib/libmyapp_jni.so.0.0.0: /usr/local/lib/libmyapp_jni.so.0.0.0: undefined symbol: __cxa_pure_virtual
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1854)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.myapp.myapp.main(myapp.java:11)
通过使用 ldd -d /usr/local/lib/libmyapp_jni.so.0.0.0
$ldd -d /usr/local/lib/libmyapp_jni.so.0
linux-vdso.so.1 => (0x00007ffffedfe000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007feacde2a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007feacdc26000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007feacda0e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007feacd7f8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007feacd42f000)
/lib64/ld-linux-x86-64.so.2 (0x00007feace5a2000)
undefined symbol: __cxa_pure_virtual (/usr/local/lib/libmyapp_jni.so.0)
undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE (/usr/local/lib/libmyapp_jni.so.0)
undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE (/usr/local/lib/libmyapp_jni.so.0)
undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE (/usr/local/lib/libmyapp_jni.so.0)
undefined symbol: _ZSt7nothrow (/usr/local/lib/libmyapp_jni.so.0)
undefined symbol: __gxx_personality_v0 (/usr/local/lib/libmyapp_jni.so.0)
我真的想知道哪里出错了?
有什么想法吗?
非常感谢。