简体   繁体   English

System.loadLibrary适用于OpenJDK,但不适用于Oracle

[英]System.loadLibrary works on OpenJDK but not on Oracle

I implemented a SDK in C++ (API exported in C). 我用C ++实现了一个SDK(用C导出的API)。 This SDK compiles into a DLL for Windows and a .so for Linux. 此SDK编译为Windows的DLL和Linux的.so。 I also implemented a Java wrapper using JNA. 我还使用JNA实现了Java包装器。 This wrapper ships with .so and DLL inside it and I check at runtime which operation system is running and extract it on a folder specified by developer. 这个包装器里面装有.so和DLL,我在运行时检查哪个操作系统正在运行,并在开发人员指定的文件夹中提取它。 It works well. 它运作良好。

The problem is that one of customers that use Linux (I have just a couple of them on Linux) said that the library was not loading with a undefined symbol error. 问题是使用Linux的客户之一(我在Linux上只有几个)表示该库没有加载未定义的符号错误。 Here is the error: 这是错误:

java.lang.UnsatisfiedLinkError: /usr/lib/libBXSDK.so: /usr/lib/libBXSDK.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE java.lang.UnsatisfiedLinkError:/usr/lib/libBXSDK.so:/usr/lib/libBXSDK.so:unfined defined symbol:_ZTVN10__cxxabiv117__class_type_infoE

Initially I thought this could be related to some standard .so not being present. 最初我认为这可能与某些标准有关。因此不存在。 I then sent him aa very basic C++ executable and asked him to run. 然后我给他发了一个非常基本的C ++可执行文件并要求他运行。 It worked. 有效。 I then sent him a very basic Java application that DOES NOT use the SDK, but only calls System.loadLibrary("BXSDK"). 然后我给他发了一个非常基本的Java应用程序,它不使用SDK,但只调用System.loadLibrary(“BXSDK”)。 After copying libBXSDK.so to /usr/lib, he ran the basic Java application and the error was the same. 将libBXSDK.so复制到/ usr / lib后,他运行了基本的Java应用程序,错误是一样的。

I then decided to check his Java version, and realized he was using Oracle JDK latest version, and I saw that on my test environment that runs CentOS 7 (customer runs RHEL 7) I use OpenJDK. 然后我决定检查他的Java版本,并意识到他正在使用Oracle JDK最新版本,我在运行CentOS 7的测试环境中看到了这一点(客户运行RHEL 7)我使用的是OpenJDK。 Immediately I installed Oracle JDK on my test environment and I saw the same problem. 我立即在我的测试环境中安装了Oracle JDK,我看到了同样的问题。

So, my question is. 所以,我的问题是。 What is the difference between Oracle JRE and OpenJDK (JRE), that causes this issue? Oracle JRE和OpenJDK(JRE)之间的区别是什么导致了这个问题? Am I doing something wrong on my .so that OpenJDK is able to handle but Oracle JRE is not? 我在我的.so上做错了,OpenJDK能够处理但是Oracle JRE不是吗?

Thanks 谢谢

Did you verify if the folder is the case as mentioned in this post: http://ubuntuforums.org/showthread.php?t=1323888 您是否验证了此文件夹中是否包含该文件夹: http//ubuntuforums.org/showthread.php?t = 1323288

Fellow (dontexist) member's comment is quite valid in general, the fact that OpenJDK being able to make the calls makes me think if library load itself was unsuccessful. 研究员(dontexist)成员的评论总的来说非常有效,OpenJDK能够进行调用的事实让我想到了库加载本身是不成功的。

I figured, this may not entail an answer to the question - "What is the difference between Oracle and Open JDK in loading semantics". 我想,这可能不会回答这个问题 - “Oracle和Open JDK在加载语义方面有什么区别”。 Not sure if I can retract this post being an answer, but let others take the opportunity to explain about it. 不确定我是否可以撤回这篇文章作为答案,但让别人借此机会解释一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM