java读取.so文件,本地可以,部署到linux后报错,求解!!
项目中,需要用到C库,通过JNI进行调用,C库打包文件名称为:libecgqrs.dll、libecgqrs.so.
我在本地windows系统下测试过了,java加载.dll和.so文件都是没有问题。
本地加载方式为: System.load("D:/libecgqrs.dll"); 或者 System.load("D:/libecgqrs.so"); 这两种都测过,没有问题的。
阿里云ECS中加载方式为: System.load("/home/ecglibfile/libecgqrs.so"); 或者System.load("/home/ecglibfile/libecgqrs.dll"); 加载方式一样,只是绝对路径不同,这两种都加载失败,报错信息如下:
Java HotSpot(TM) 64-Bit Server VM warning: You have loaded library /home/ecglibfile/libecgqrs.so which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.UnsatisfiedLinkError: /home/ecglibfile/libecgqrs.so: /home/ecglibfile/libecgqrs.so: invalid ELF header (Possible cause: endianness mismatch)
Caused by: java.lang.UnsatisfiedLinkError: /home/ecglibfile/libecgqrs.so: /home/ecglibfile/libecgqrs.so: invalid ELF header (Possible cause: endianness mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
做过这方面的兄弟们,知道这是为什么不? 在线求解~~~~