[英]LD_PRELOAD variable in JNI code
My java code calls via JNI some C++ code from a shared library (eg libtest.so). 我的Java代码通过JNI从共享库(例如libtest.so)中调用了一些C ++代码。 The code is instrumented with some special debugging symbols that exist it libdebug.so.
该代码使用libdebug.so中存在的一些特殊调试符号进行检测。 When I call
当我打电话
LD_PRELOAD=/usr/lib/libdebug.so java com.test.myMain
LD_PRELOAD = / usr / lib / libdebug.so java com.test.myMain
the execution stops with Exception in thread "main" java.lang.UnsatisfiedLinkError
执行
Exception in thread "main" java.lang.UnsatisfiedLinkError
以Exception in thread "main" java.lang.UnsatisfiedLinkError
停止
because symbols from libdebug.so are not loaded (why?). 因为libdebug.so中的符号未加载(为什么?)。
I was wondering if it is possible to modify my code in order to PRELOAD the library inside my java code. 我想知道是否可以修改我的代码以便在Java代码中预加载该库。 (Of course I don't want to compile java with libdebug.so...)
(当然,我不想用libdebug.so来编译Java ...)
System.load
can be used to load any shared library, so you might try loading the debug library in a static block using System.load
(before you load your JNI lib). System.load
可用于加载任何共享库,因此,您可以尝试使用System.load
在静态块中加载调试库(在加载JNI库之前)。 Or try System.loadLibary("debug")
before your JNI lib. 或在您的JNI库之前尝试
System.loadLibary("debug")
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.