jnr / jnr-ffi

Java Abstracted Foreign Function Layer
Other
1.25k stars 156 forks source link

Unsatisfied link when used in conjunction with jnr-posix #300

Open Melab opened 2 years ago

Melab commented 2 years ago

I have been attempting to use jnr-posix's native function calls inside GraalVM JavaScripy, but I have gotten error message that complain about an unsatisified link.

I cloned the following repositories at their linked-to commits:

In the top-level of each repository, I ran mvn -B package --file pom.xml. This produced several JAR files, the following of which I copied to ${JNR_JARS_DIR}:

graaljs+jnr.sh is the shell scrupt that I used to test two JavaScript files, one of which uses DefaultPOSIXHandler and one which does not. The commands were as follows

graaljs+jnr.sh "Without DefaultPOSIXHandler.js" &> "Without DefaultPOSIXHandler.log"
graaljs+jnr.sh "With DefaultPOSIXHandler.js" &> "With DefaultPOSIXHandler.log"

The script includes the previously mentioned JAR files in the classpath of the executed java command.

Both attempts to retrieve the native POSIX interface fail with java.lang.UnsatisfiedLinkError.

The relevant files:

headius commented 2 years ago

At a glance it appears you did things correctly. Can you provide more information about your system? Specifically I want to know what OS and CPU you are running on, in case the issue is platform-specific.

headius commented 2 years ago

Looking over the code around the error, it is hard to tell why the library was unable to load. Some extra information from you would be helpful:

I believe the problem is perhaps something in your environment, but more likely it is due to GraalJS itself having trouble or preventing our native library from loading. The same basic code you provided loads and works ok from a normal Java application.

Melab commented 2 years ago

At a glance it appears you did things correctly. Can you provide more information about your system? Specifically I want to know what OS and CPU you are running on, in case the issue is platform-specific.

CPU is AMD G-T56N. Operating system is Ubuntu 20.04. Kernel is Ubuntu Linux 5.11.0-27-generic.

Melab commented 2 years ago

Looking over the code around the error, it is hard to tell why the library was unable to load. Some extra information from you would be helpful:

* What version of GraalJS are you running?

* Is it possible for you to enable some native logging in GraalJS? As a JVM flag that would be `-verbose:jni` but I do not know how GraalJS is set up in your environment.

I believe the problem is perhaps something in your environment, but more likely it is due to GraalJS itself having trouble or preventing our native library from loading. The same basic code you provided loads and works ok from a normal Java application.

It's the GraalVM JavaScript that comes with GraalVM Community Edition 21.3.0 for Java 11. I'm running it in JVM mode.

Relevant files:

Scripts are still the same.

Melab commented 2 years ago

Is there any news yet?