JNA UnsatisfiedLinkError linux custom lib not work

586 views
Skip to first unread message

Алексей Поляков

unread,
Jul 8, 2015, 7:58:19 AM7/8/15
to jna-...@googlegroups.com
Hello! Sorry for my english. I need help. I'm trying to call "Native.loadLibrary" from java, in windows it's all ok, but in linux (64 bit) it's not work. With standard library (example: Native.loadLibrary("c", ...) it's work, but with my custom lib name Native.loadLibrary("sdkencryptedappticket", ..) not work.
Log is:
Looking in classpath from sun.misc.Launcher$AppClassLoader@11e55d39 for /com/sun/jna/linux-x86-64/libjnidispatch.so
Found library resource at jar:file:/root/SteamAppTicket/lib/jna-4.1.0.jar!/com/sun/jna/linux-x86-64/libjnidispatch.so
Looking for library 'sdkencryptedappticket'
Adding paths from jna.library.path: /usr/lib64
Trying /usr/lib64/libsdkencryptedappticket.so
Adding system paths: [/usr/lib64, /lib64, /usr/lib, /lib]
Trying /usr/lib64/libsdkencryptedappticket.so
Looking for version variants
Looking in classpath from sun.misc.Launcher$AppClassLoader@11e55d39 for sdkencryptedappticket
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'sdkencryptedappticket': Native library (linux-x86-64/libsdkencryptedappticket.so) not found in resource path ([file:/root/SteamAppTicket/SteamAppTicket.jar])
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
    at com.sun.jna.Library$Handler.<init>(Library.java:147)
    at com.sun.jna.Native.loadLibrary(Native.java:412)
    at com.sun.jna.Native.loadLibrary(Native.java:391)
    at steamappticket.SteamAppTicket.<clinit>(SteamAppTicket.java:31)


"Trying /usr/lib64/libsdkencryptedappticket.so" and file 100% in this folder, all permissions is "root" user and "0777".

Jar call is:
nohup /root/Distr/jre/bin/java -Djna.debug_load=true -Djna.library.path="/usr/lib64" -jar -Xmx10m SteamAppTicket.jar &

I'm try variants:
1) full path to .so inside Native.loadLibrary
2) move .so to folder where is .jar
3) create sym link in folder with .jar
4) move .so to /usr/lib and /usr/lib64 and /lib and /lib64
5) 4 variant with create sym links
6) with or without -Djna.library.path="/usr/lib64" or ="/root/SteamAppTicket" etc. and with -Djava.library.path
totally not working

Алексей Поляков

unread,
Jul 8, 2015, 8:01:21 AM7/8/15
to jna-...@googlegroups.com
+ try add .so to linux-x86-64/ inside jar folder, inside path/lib etc

Алексей Поляков

unread,
Jul 8, 2015, 8:06:28 AM7/8/15
to jna-...@googlegroups.com
+ try this on 2 remote systems - vps ( /root/Distr/jre/bin/java installation of java 1.7) and vds (global installation of java 1.7). can't test locally

Алексей Поляков

unread,
Jul 8, 2015, 8:08:44 AM7/8/15
to jna-...@googlegroups.com
+ try this with nohup java (from .sh) and from command line.

Алексей Поляков

unread,
Jul 8, 2015, 8:12:13 AM7/8/15
to jna-...@googlegroups.com
+ try copy libc.so to jar folder and rename to jar/libc_123123.so, and write Native.loadLibrary("c_123123", ...) - not found libc_123123.so

Алексей Поляков

unread,
Jul 8, 2015, 11:28:03 AM7/8/15
to jna-...@googlegroups.com
I found solution after hours.. problem is glibc version.
ldd /root/SteamAppTicket/libsdkencryptedappticket.so
result:
/root/SteamAppTicket/libsdkencryptedappticket.so: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /root/SteamAppTicket/libsdkencryptedappticket.so)

in other system with centos 7 and glibc 2.17 all is ok.

why jna not explain reasons?! it write "not found .so" but not related .so version mismatch.
may be "Looking for version variants"? not clear..

Timothy Wall

unread,
Jul 9, 2015, 7:20:45 AM7/9/15
to jna-...@googlegroups.com
Normally JNA will use any error message (strerror) from the dlopen call as the message for the UnsatisfiedLinkError exception. Perhaps the OS is not actually providing that message when dlopen() is called?

I typically do the linux builds against a someone older system (older glibc), but I don’t recall the version offhand.
> --
> You received this message because you are subscribed to the Google Groups "Java Native Access" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages