woodser / monero-java

Java library for using Monero
https://woodser.github.io/monero-java/javadocs/
MIT License
105 stars 39 forks source link

Native libraries failing on Windows with `UnsatisfiedLinkError` [2 XMR] #82

Closed woodser closed 5 months ago

woodser commented 5 months ago

Currently, native libraries are built for Windows, producing these files:

However, using the native libraries results in an error when using JNI functions: "UnsatisfiedLinkError".

To reproduce the failure in a test:

  1. On Windows, download Visual Studio Code and install Java extensions.
  2. Import the monero-java project into workspace.
  3. Build or download the Windows native libraries to the ./build folder.
  4. Open TestMoneroUtils.java and click the button to run testGetIntegratedAddresses().
  5. The test should succeed, but instead fails with UnsatisfiedLinkError:

image

github-actions[bot] commented 5 months ago

There is a bounty on this issue. The amount is in the title. The reward will be awarded to the first person or group of people who resolve this issue.

If you are starting to work on this bounty, please write a comment so that we can assign the issue to you. We expect contributors to provide a PR in a reasonable timeframe or, in case of an extensive work, updates on their progress. We will unassign the issue if we feel the assignee is not responsive or has abandoned the task.

Read the full conditions and details of the bounty system.

everoddandeven commented 5 months ago

I'm trying to debug, it seems that libmonero-java.dll failed to load other dlls:

image

everoddandeven commented 5 months ago

I just put C:\msys64\mingw64\bin the Path environment variable and now it works:

image

I don't know if it is a good solution, maybe compiling the library with -static param can solve this issue

woodser commented 5 months ago

Hm, I tried adding C:\msys64\mingw64\bin to the Path environment variable, but I'm still getting the UnsatisfiedLinkError running the test in VS Code.

Dependency walker looks much better after adding to Path, though:

image
woodser commented 5 months ago

This issue is resolved with https://github.com/woodser/monero-java/commit/45360d1d901af7b9d59ade2177d65d11c503bc73, and the bounty is paid. Thanks @everoddandeven!