O
OtisUsenet
Hi,
I have a shared library that I am trying to load, but I'm hitting the
wall. I was wondering if anyone could help.
The library (.so) lives in:
/dev/cLib.
I run my app as:
java -Djava.library.path=/dev/cLib com.example.MyApp
I try to load the library from MyApp like this:
static {
System.out.println("1: " +
System.getProperty("java.library.path"));
System.out.println("2: " + System.mapLibraryName("Foo"));
System.out.println("Loading Foo.so");
System.load("/dev/cLib/libFoo.so");
System.out.println("Loaded");
}
This results in:
1: /dev/cLib
2: libFoo.so
Loading libFoo.so
Loaded
Exception in thread "main" java.lang.UnsatisfiedLinkError: init
at com.example.MyApp.init(Native Method)
I also tried this:
System.loadLibrary("libFoo.so"); // also tried without the .so
extension
That gave me:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libFoo.so
in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
If I switch to using just this:
System.loadLibrary("Foo"); // no lib prefix, no .so extension
Then I again get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: init
Does anyone know what's going on here?
I've never worked with shared libraries and JNI before, so I'm not even
sure if this is how things are supposed to work. Is this how I should
be loading a shared library?
Also, if this helps (doesn't mean much to me), this is what ldd says
about my library:
$ ldd -v /dev/cLib/libFoo.so
statically linked
Version information:
/lib/libNoVersion.so.1:
libc.so.6 (GLIBC_2.0) => /lib/tls/libc.so.6
libc.so.6 (GLIBC_2.1.3) => /lib/tls/libc.so.6
/lib/tls/libc.so.6:
ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2
Any help would be greatly appreciated.
Thank you!
I have a shared library that I am trying to load, but I'm hitting the
wall. I was wondering if anyone could help.
The library (.so) lives in:
/dev/cLib.
I run my app as:
java -Djava.library.path=/dev/cLib com.example.MyApp
I try to load the library from MyApp like this:
static {
System.out.println("1: " +
System.getProperty("java.library.path"));
System.out.println("2: " + System.mapLibraryName("Foo"));
System.out.println("Loading Foo.so");
System.load("/dev/cLib/libFoo.so");
System.out.println("Loaded");
}
This results in:
1: /dev/cLib
2: libFoo.so
Loading libFoo.so
Loaded
Exception in thread "main" java.lang.UnsatisfiedLinkError: init
at com.example.MyApp.init(Native Method)
I also tried this:
System.loadLibrary("libFoo.so"); // also tried without the .so
extension
That gave me:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libFoo.so
in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:992)
If I switch to using just this:
System.loadLibrary("Foo"); // no lib prefix, no .so extension
Then I again get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: init
Does anyone know what's going on here?
I've never worked with shared libraries and JNI before, so I'm not even
sure if this is how things are supposed to work. Is this how I should
be loading a shared library?
Also, if this helps (doesn't mean much to me), this is what ldd says
about my library:
$ ldd -v /dev/cLib/libFoo.so
statically linked
Version information:
/lib/libNoVersion.so.1:
libc.so.6 (GLIBC_2.0) => /lib/tls/libc.so.6
libc.so.6 (GLIBC_2.1.3) => /lib/tls/libc.so.6
/lib/tls/libc.so.6:
ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2
ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2
Any help would be greatly appreciated.
Thank you!