- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我得到类似以下内容:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no viewerNativeDLL in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at viewer.SarBufferedImage.<clinit>(SarBufferedImage.java:356)
at viewer.viewerJPanel.<init>(viewerJPanel.java:34)
at viewer.ViewerView.initComponents(ViewerView.java:457)
at viewer.ViewerView.<init>(ViewerView.java:33)
at viewer.ViewerApp.main(ViewerApp.java:21)
即使我已将 LD_LIBRARY_PATH 设置为我构建共享对象的路径。
我是否构建了错误的共享对象?这是我用来构建共享库的 makefile:
CPP = g++
CFLAGS = -O3 -Wall -fopenmp -fPIC
INC = -I ../../VC/readers/ -I../../VC/writers -I../../VC/common/ -I /home/dcole/software/xerces-c-3.1.1/src -I /home/dcole/software/java/jdk1.6.0_23/include -I /home/dcole/software/java/jdk1.6.0_23/include/linux
LIB2 = -L/usr/lib64/ -L../../lib/IDT.a -L../../lib/Linux/libxerces-c.a -L../../lib/Linux/libxerces-c-3.1.so -lcurl -lidn -ldl -lssl -L../../lib/Linux/libfftw3f.a -lpthread
all: ViewerNative.o
${CPP} ${CFLAGS} -shared -o libviewerNativeDLL.so ViewerNative.o ${LIB2}
ViewerNative.o: ViewerNative.cpp viewer_SarBufferedImage.h
${CPP} ${INC} ${CFLAGS} -c ViewerNative.cpp ${LIB2}
我创建 viewerNativeDLL.so 的方式是否遗漏了什么?
如果我执行 ldd-d libviewerNativeDLL.so 我得到这个:
undefined symbol: _ZTIN11xercesc_3_117SAXParseExceptionE (./libviewerNativeDLL.so)
undefined symbol: _ZN11xercesc_3_117SAXParseExceptionD1Ev (./libviewerNativeDLL.so)
linux-vdso.so.1 => (0x00007fff41f21000)
libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007fc30bcd4000)
libidn.so.11 => /lib64/libidn.so.11 (0x00007fc30baa2000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fc30b89d000)
libssl.so.8 => /usr/lib64/libssl.so.8 (0x00007fc30b649000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc30b42d000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc30b122000)
libm.so.6 => /lib64/libm.so.6 (0x00007fc30ae9f000)
libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007fc30ac92000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc30aa77000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc30a709000)
libldap-2.4.so.2 => /usr/lib64/libldap-2.4.so.2 (0x00007fc30a4c4000)
librt.so.1 => /lib64/librt.so.1 (0x00007fc30a2bb000)
libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007fc30a090000)
libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007fc309df4000)
libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007fc309bcd000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007fc3099ca000)
libz.so.1 => /lib64/libz.so.1 (0x00007fc3097b5000)
libssl3.so => /lib64/libssl3.so (0x00007fc309581000)
libsmime3.so => /lib64/libsmime3.so (0x00007fc309357000)
libnss3.so => /lib64/libnss3.so (0x00007fc309024000)
libnssutil3.so => /lib64/libnssutil3.so (0x00007fc308e05000)
libplds4.so => /lib64/libplds4.so (0x00007fc308c02000)
libplc4.so => /lib64/libplc4.so (0x00007fc3089fe000)
libnspr4.so => /lib64/libnspr4.so (0x00007fc3087c1000)
libssh2.so.1 => /usr/lib64/libssh2.so.1 (0x00007fc30859a000)
/lib64/ld-linux-x86-64.so.2 (0x0000003e34a00000)
libcrypto.so.8 => /usr/lib64/libcrypto.so.8 (0x00007fc308215000)
liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007fc308005000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fc307dec000)
libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007fc307bd1000)
libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007fc3079c8000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007fc3077c6000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fc30758e000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fc307370000)
libfreebl3.so => /lib64/libfreebl3.so (0x00007fc307113000)
所以我可以清楚地看到它们丢失了,但为什么我没有收到任何错误?解决方法是什么?我已经从 xerces 链接到静态库和共享库
编辑:当我尝试运行它时,我现在实际上得到了这个:
$ java -Djava.library.path=/home/dcole/IM/work/ext/VC.viewer/viewerNativeDLL/ -jar viewer.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/dcole/IM/work/ext/VC.viewer/viewerNativeDLL/libviewerNativeDLL.so: /home/dcole/IM/work/ext/VC.viewer/viewerNativeDLL/libviewerNativeDLL.so: undefined symbol: _ZTIN11xercesc_3_117SAXParseExceptionE
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at viewer.SarBufferedImage.<clinit>(SarBufferedImage.java:356)
at viewer.viewerJPanel.<init>(viewerJPanel.java:34)
at viewer.ViewerView.initComponents(ViewerView.java:457)
at viewer.ViewerView.<init>(ViewerView.java:33)
at viewer.ViewerApp.main(ViewerApp.java:21)
编辑2:
按照下面的建议,我更改了我正在链接到库的说法,这给了我这个命令和输出:
g++ -O3 -Wall -fopenmp -fPIC -shared -o libviewerNativeDLL.so ViewerNative.o -L/usr/lib64/ ../../lib/IDT.a ../../lib/Linux/libxerces-c.a ../../lib/Linux/libxerces-c-3.1.so -lcurl -lidn -ldl -lssl ../../lib/Linux/libfftw3f.a -lpthread
/usr/bin/ld: ../../lib/Linux/libxerces-c.a(PlatformUtils.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
../../lib/Linux/libxerces-c.a: could not read symbols: Bad value
我想我必须用 fPIC 重新编译 xerces?
最佳答案
我认为原因是您链接到库的方式:
-L../../lib/Linux/libxerces-c-3.1.so
-L
选项用于指定库的搜索目录,库本身使用 -l
选项指定。
大概应该是:
-L../../lib/Linux/ -lxerces-c-3.1
或者只是把没有-L
的lib放在
../../lib/Linux/libxerces-c-3.1.so
编辑:
您可以检查 nm libxerces-c-3.1.so|grep ParseException
(对于 libxerces-c.a 也是如此)是否定义了这样的符号。还要确保用于编译的 libxerces(包括路径 -I)和用于链接的 libxerces 相同。
在链接库时传递 -Wl,-no-undefined
将帮助您在链接期间看到 undefined symbol ,而不是稍后尝试加载库。
关于java - 共享库编译,但有 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4596271/
我只是有一个更琐碎的问题。 为什么undefined == undefined 返回true,而undefined >= undefined 为false? undefined 等于 undefine
用PHP 7.2编写套接字服务器。根据Firefox 60中的“网络”选项卡,服务器的一些HTTP响应的第一行随机变为undefined undefined undefined。因此,我尝试记录套接字
在 JavaScript 中这是真的: undefined == undefined 但这是错误的: undefined <= undefined 起初我以为<=运算符包含第一个,但我猜它试图将其转换
在回答这个问题 (Difference between [Object, Object] and Array(2)) 时,我在 JavaScript 数组中遇到了一些我以前不知道的东西(具有讽刺意味的
来自https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/of , Note: thi
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
当我添加 到我的 PrimeFaces Mobile 页面,然后我在服务器日志中收到以下警告 WARNING: JSF1064: Unable to find or serve resource, u
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我正在运行 PHP 脚本并继续收到如下错误: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php
我是一名优秀的程序员,十分优秀!