Can't Load C Library on amd_64

96 views
Skip to first unread message

Crt Tsai

unread,
Jun 20, 2011, 4:22:03 PM6/20/11
to Java Native Access
Dear all,

I'd download the latest version of JNA (jna.jar & platform.jar) and
try to use it. I'm sure that I've already export the CLASSPATH and
LD_LIBRARY_PATH but I can still find the error below(even if I only
want to run the HelloWorld sample file):

Exception in thread "main" java.lang.UnsatisfiedLinkError:
com.sun.jna.Native.open(Ljava/lang/String;)J
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:
236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at HelloWorld$CLibrary.<clinit>(HelloWorld.java:12)
at HelloWorld.main(HelloWorld.java:40)

I also have the version before and they still works good.
I wonder why the error happen? Or I did something wrong?

Here is the information of the machine:
$ uname -a
Linux 2.6.39-1-amd64 #1 SMP Tue May 24 14:34:19 UTC 2011 x86_64 GNU/
Linux

---

Also I do the same thing with latest version JNA on another machine
(Linux 2.6.35.13-91.fc14.i686.PAE #1 SMP Tue May 3 13:29:55 UTC 2011
i686 i686 i386 GNU/Linux)

And they works good.

Thanks.

dblock

unread,
Jun 21, 2011, 7:21:22 AM6/21/11
to Java Native Access
So this worked with the 3.2.7 version and stopped working with 3.3.0?
If you swap jna.jar back from 3.2.7 it just works?

If that's the case we have a bug. Make a small repro and file it in
https://github.com/twall/jna/issues, upload the repro to dropbox or
something like that.

Timothy Wall

unread,
Jun 21, 2011, 11:12:55 AM6/21/11
to Java Native Access
Whenever you upgrade any java libraries in your project, you need to
clean out all your old class files to ensure that you compile against
the newer version. Sometimes what's compatible at the source level is
not compatible at the binary level.

On Jun 20, 4:22 pm, Crt Tsai <crist.schooltheel...@gmail.com> wrote:

Crt Tsai

unread,
Jun 22, 2011, 6:16:47 AM6/22/11
to Java Native Access
Thanks Timothy Wall.
I'd tried to remove old class file but it still not work. :(

(Thanks dblock too.)
So I made a issue at : https://github.com/twall/jna/issues/5

-

Actually I found out something strange.
When I first use $java helloworld, it works! And after I cd to another
directory and change back, it have error :

Exception in thread "main" java.lang.UnsatisfiedLinkError:
com.sun.jna.Native.open(Ljava/lang/String;)J
at com.sun.jna.Native.open(Native Method)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:
236)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at helloworld$CLibrary.<clinit>(helloworld.java:9)
at helloworld.main(helloworld.java:17)

-

But in CallLib.java I try to call a C library, it's not such lucky :

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to
load library 'cvoidcall': com.sun.jna.Native.open(Ljava/lang/String;)J
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:
166)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:
239)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:393)
at com.sun.jna.Native.loadLibrary(Native.java:378)
at CallLib$HLibrary.<clinit>(CallLib.java:8)
at CallLib.main(CallLib.java:21)

-

Thanks.

Timothy Wall

unread,
Jun 22, 2011, 7:00:00 AM6/22/11
to jna-...@googlegroups.com

On Jun 22, 2011, at 6:16 AM, Crt Tsai wrote:

> Thanks Timothy Wall.
> I'd tried to remove old class file but it still not work. :(
>
> (Thanks dblock too.)
> So I made a issue at : https://github.com/twall/jna/issues/5
>
> -
>
> Actually I found out something strange.
> When I first use $java helloworld, it works! And after I cd to another
> directory and change back, it have error :

You mean you cd in the shell from which you're launching your java program?

Both of these errors look like your native library path needs fixing. Does your system have a version of libjnidispatch.so in LD_LIBRARY_PATH (or libjnidispatch.dll in PATH) (first error)?

Make sure the path to the library that contains your 'cvoidcall' function is either in LD_LIBRARY_PATH/PATH or jna.library.path (second error).

Crt Tsai

unread,
Jun 23, 2011, 3:24:47 AM6/23/11
to Java Native Access
I found out that's my fault.
I forgot to remove the old version of jnidispatch.so in the directory
cause I did the profiling before.
I'm really sorry about that.
Sorry, and thanks Timothy Wall's remind.
Reply all
Reply to author
Forward
0 new messages