Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

UnsatisfiedLinkError when loading native libraries in Linux

843829Sep 8 2006 — edited Sep 25 2006
Hi, folks.

I'm currently in the process of writing a Java wrapper for a c++ library, which is in turn associated with a driver for a particular I/O card (none of which is important). The problem I'm running into is as follows:

There are three shared objects that need to be loaded: one which contains the actual JNI methods (libni_system_jni.so), one which is our c++ library (libni.so), and one which contains, among other things, our c++ exception classes (libcommon.so), instances of which are thrown by functions in libni.so, and so need to be caught by the methods in libni_system_jni.so.

The thing is, when I actually try to run a test program that uses the java wrapper, I get an UnsatisfiedLinkError, telling me that "_ZN9ExceptionC2ESs" is an undefined symbol (Exception is the name of our c++ base exception class). This despite the fact that I load the libraries in order---first libcommon.so, then libni.so, then, finally, libni_system_jni.so, like so:
static {
  System.loadLibrary("common");
  System.out.println("Loaded common.");
  System.loadLibrary("ni");
  System.out.println("Loaded ni.");
  System.loadLibrary("ni_system_jni");
  System.out.println("Loaded ni_system_jni.");
}
I've checked; all three shared objects are in the directory I specified on the command line (-Djava.library.path=/home/pipegeek/ni/lib). What's more, an earlier, simpler version (which only needed to load libni_system_jni.so) worked fine. I do have c++ code that uses all of these libraries (less the jni one), and it, also, works fine.

To recap: I'm trying to load a native library with jni methods, and the library that it depends on, and the library that it depends on. The last is either not loading, or somehow not being noticed when loading the other two. What gives?

Thanks for any help you can provide.

PTR

P.S. My output, with the specific error, follows:
Loaded common.
Exception in thread "main" java.lang.UnsatisfiedLinkError: /home/pipegeek/pinball/lib/libni.so: /home/pipegeek/pinball/lib/libni.so: undefined symbol: _ZN9ExceptionC2ESs
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1676)
	at java.lang.Runtime.loadLibrary0(Runtime.java:822)
	at java.lang.System.loadLibrary(System.java:992)
	at pinball.system.Driver.<clinit>(Driver.java:13)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2006
Added on Sep 8 2006
1 comment
401 views