Question

My java code calls via JNI some C++ code from a shared library (eg libtest.so). The code is instrumented with some special debugging symbols that exist it libdebug.so. When I call

LD_PRELOAD=/usr/lib/libdebug.so java com.test.myMain

the execution stops with Exception in thread "main" java.lang.UnsatisfiedLinkError

because symbols from libdebug.so are not loaded (why?).

I was wondering if it is possible to modify my code in order to PRELOAD the library inside my java code. (Of course I don't want to compile java with libdebug.so...)

Was it helpful?

Solution

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). Or try System.loadLibary("debug") before your JNI lib.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top