Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaCPP-based platform bindings (LibreMidiAccess, RtMidiAccess) fail to resolve jars to the native bindings #98

Open
atsushieno opened this issue Feb 6, 2025 · 5 comments

Comments

@atsushieno
Copy link
Owner

It seems that apps (at least Compose Desktop apps like ktmidi-ci-tool) that depend on the latest JavaCPP based bindings fail to resolve the Jars that contain native libraries (e.g. libremidi-javacpp-linux-x86_64.jar) and thus fails at run time:

> Task :ktmidi-ci-tool:run
Warning: Version of dev.atsushieno:libremidi_javacpp could not be found.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnilibremidi in java.library.path: /Users/atsushi/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Version of dev.atsushieno:libremidi_javacpp could not be found.

There seems some issue around packaging and/or package resolution with gradle-javacpp. The Gradle plugin org.bytedeco.gradle-javacpp-platform, along with api(libs.libremidi.javacpp.platform) (versions in libs.versions.toml), should transform the api() reference to the native library bindings, but it is somehow not triggered.

There are some findings:

  • If the bindings (libremidi-javacpp or rtmidi-javacpp) were put in the local Maven repository (via publishToMavenLocal), the Compose Desktop apps successfully contain the native bindings.
  • Package files are successfully published at least at libremidi-javacpp v0.1.4.
  • input-sample and player-sample work on the IDE too, IF libremidi-javacpp is published locally.

confirmed at: c24dc1a

@rkechols
Copy link

rkechols commented Feb 6, 2025

I've opened an issue with gradle-javacpp to see if anyone there can help diagnose/fix the issue:
bytedeco/gradle-javacpp#33

@rkechols
Copy link

rkechols commented Feb 6, 2025

In the meantime, my best guess is that the problem is that the platform-specific artifacts are published under libremidi-javacpp (here), rather than with the -platform suffix here.

@atsushieno
Copy link
Owner Author

I think I'm following what javacpp-presets does, for example:

@atsushieno
Copy link
Owner Author

I wrote a bit more about it at atsushieno/libremidi-javacpp@f50ebff

@atsushieno
Copy link
Owner Author

There seems no single working example of gradle-javacpp based library that was successfully published to Maven Central and proved its usefulness yet. We might have to give up current build setup.

At this state, there are some alternative options I can think of:

  • Rewrite libremidi-javacpp to dump Gradle and use Maven instead: if the problem is only publishing package, then it would be the remedy. But if there is any problem in javacpp-gradle-platform too, there is no escape hatch.
  • Get libremidi-panama working: there are many steps to go over. panama jextract is not as user-friendly as javacpp and we have to hack library loader, packaging integration, and so on. Also libremidi-panama itself is not known to work. And Panama API itself is not stable yet.
  • switch to JNA. But since JNAerator is not maintained anymore, we might have to manually create API bindings. Then the same loader and packager issues are there. Not sure how long JNA will be maintained in favor of Panama.

Although in the meantime, it is very likely that submoduling libremidi-javacpp, build and perform publishToMavenLocal would fix local issues as well as app packaging issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants