E
E
evrikom2018-02-20 11:17:11
Java
evrikom, 2018-02-20 11:17:11

JNA. Why can't I load the C library?

did following the example with stuf.ro/calling-c-code-from-java-using-jna
if run through the main class

java -Djna.library.path=/home/user/1 -Djna.debug_load=true com/mycompany/testjna/HelloWorld

the library is loaded and the function is called.
...
Found library 'ctest' at /home/user/1/libctest.so
Hello from C!

However, if you make a jar and run it:
java -Djna.library.path=/home/user/1 -jar testJNA-1.0-SNAPSHOT-jar-with-dependencies.jar

an error occurs:
[email protected]:~/NetBeansProjects/testJNA/target$ java -Djna.library.path=/home/user/1 -jar testJNA-1.0-SNAPSHOT-jar-with-dependencies.jar 
arch:x86 prefix:linux-x86 libName:c
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/jna--1364653087/jna7467041216767909949.tmp: /tmp/jna--1364653087/jna7467041216767909949.tmp: сбой отображения сегмента из разделяемого объекта
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-02-20
@evrikom

noexecThe problem is the /tmp mount option , which does not allow anything to be executed from the temporary directory. You need to either remount without it, or try to start the virtual machine with the parameter jna.tmpdirpointing somewhere else.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question