我正在尝试在Amazon EC2实例上调用Ubuntu上的共享库 相同的代码在Windows上运行100%,但在Ubuntu上 - 当我尝试运行它时,我得到一个java.lang.UnsatisfiedLinkError
当我在共享库上运行ldd时 - 所有依赖项似乎都得到满足
root@ip-172-31-14-36:/var/lib/tomcat8/conf# ldd /tmp/dll/linux/v1/release/myConvertor.so
linux-vdso.so.1 => (0x00007ffed4ffd000)
libQt5Widgets.so.5 => /tmp/dll/linux/v1/release/libQt5Widgets.so.5 (0x00007fa81daff000)
libQt5Gui.so.5 => /tmp/dll/linux/v1/release/libQt5Gui.so.5 (0x00007fa81d2ec000)
libQt5Xml.so.5 => /tmp/dll/linux/v1/release/libQt5Xml.so.5 (0x00007fa81d0b0000)
libQt5Network.so.5 => /tmp/dll/linux/v1/release/libQt5Network.so.5 (0x00007fa81cd57000)
libQt5Core.so.5 => /tmp/dll/linux/v1/release/libQt5Core.so.5 (0x00007fa81c610000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa81c3e6000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fa81c064000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fa81bd5a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fa81bb44000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa81b77a000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fa81b526000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007fa81b324000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fa81b11c000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fa81ae0a000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fa81abf8000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fa81a8be000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007fa81a64b000)
libicui18n.so.54 => /usr/lib/libicui18n.so.54 (0x00007fa81a1f7000)
libicuuc.so.54 => /usr/lib/libicuuc.so.54 (0x00007fa819e66000)
libicudata.so.54 => /usr/lib/libicudata.so.54 (0x00007fa81843c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa818238000)
/lib64/ld-linux-x86-64.so.2 (0x0000559ebb9c1000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fa81802f000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fa817dbf000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fa817b9c000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fa817973000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007fa817770000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007fa81756c000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007fa817365000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007fa817162000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007fa816f32000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fa816d2f000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fa816b29000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007fa816926000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007fa81670d000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007fa816508000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007fa816301000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007fa8160f0000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fa815eeb000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fa815ce5000)
我加载共享库的代码如下
String dllLocation = "/tmp/dll/linux/v1/release/myConvertor.so";
canvasConversionInterface = (CanvasConversionInterface) Native.loadLibrary(dllLocation, CanvasConversionInterface.class);
我在tomcat上设置了以下系统属性
jna.library.path="/tmp/dll/linux/v1/release"
jna.debug_load=true
以下是我尝试在上面调用该行加载共享库时出现的错误
Looking in classpath from WebappClassLoader
context: ROOT
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@52d278a0
for /com/sun/jna/linux-x86-64/libjnidispatch.so
Found library resource at jar:file:/var/lib/tomcat8/webapps/ROOT/WEB-INF/lib/jna-4.5.0.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so
Looking for library '/tmp/dll/linux/v1/release/myConvertor.so'
Adding paths from jna.library.path: "/tmp/dll/linux/v1/release"
Trying /tmp/dll/linux/v1/release/myConvertor.so
Adding system paths: [/usr/lib/x86_64-linux-gnu, /lib/x86_64-linux-gnu, /lib64, /usr/lib, /lib, /usr/lib/x86_64-linux-gnu/libfakeroot, /usr/lib/x86_64-linux-gnu/mesa]
Trying /tmp/dll/linux/v1/release/myConvertor.so
Looking for version variants
Looking in classpath from WebappClassLoader
context: ROOT
delegate: false
----------> Parent Classloader:
java.net.URLClassLoader@52d278a0
for /tmp/dll/linux/v1/release/myConvertor.so
2017-10-02 13:27:21 [jmsNewPublicationQueueMessageListenerContainer-1] WARN o.s.j.l.DefaultMessageListenerContainer - Execution of JMS message listener failed, and no ErrorHandler has been set.
java.lang.UnsatisfiedLinkError: Unable to load library '/tmp/dll/linux/v1/release/myConvertor.so': Native library (tmp/dll/linux/v1/release/myConvertor.so) not found in resource path ([...
...
我可以验证上面提到的所有路径都是准确的
任何人都可以提出任何想法,我可以尝试下一步尝试并使其工作吗?
谢谢 达明
答案 0 :(得分:0)
问题在于共享库,它使用的是OpenCV 在与C ++开发人员交谈之后 - 我们发现可以从库中删除OpenCV依赖关系 一旦我们删除了这个并再次尝试 - 一切都运行良好