-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
java.lang.UnsatisfiedLinkError: no jniopenblas_nolapack in java 11 #1435
Comments
Have you tried to add a line for |
Just tried
I'm on mac. not linux |
Yeah, that's a limitation of JPMS. It's not possible to have optional modules. @HGuillemet What would be your recommendation? |
I'm not sure to understand the problem. There are some kind of optional modules in JPMS : |
ok. one more thing: I had -Djavacpp.platform=macosx-x86_64 in maven importer in intellij settings |
When declaring "dependencies", we must distinguish:
The native libraries are resources that must be accessible from your app, which means they are either in a "required" module or in the unnamed module. When you replace I need to think a bit more about best fixes. Another post coming later or tomorrow. |
@HGuillemet Would it work if we used |
Unfortunately that won't be enough. The only options I can think about are:
Do you see another option ? |
Ah, yes, I remember about that. It's actually a compile-only thing, not about optional modules.
I don't think we need any additional modules for that to work. module recorder {
requires org.bytedeco.javacv;
requires org.bytedeco.opencv.macosx.x86_64;
} It's just annoying that we have to do that... I think we could wrap all that pretty easily with a Gradle plugin in Gradle JavaCPP, if only Gradle supported JPMS: gradle/gradle#890
I don't see how that would help. Do you have an example of that? |
Yes, for each native module used by javacv. That's what I do in my modular apps, but I use the presets directly, not javacv.
The specificity of service loaders is that it can, in a JPMS compatible way, load different modules depending of what it finds in the module path. So the That could roughly work like this:
When loading opencv_core, instead of the
The resulting loader can then be used to iterate over all implementations found in the module path and select one having the right system and arch, by calling methods like Alternatively, instead of using the service facility to locate specific libraries like opencv_core, it could be used to simply locate the whole native module opencv and then we |
There is a 3rd option:
|
That sounds like a lot trouble just to load resources... I think loading the JVM with options like @jkolobok What do you think? Can you give it a try and see if that satisfies your needs?
Yeah, it looks like JavaFX also gave up on that and they've decided to just fall back on the class path: openjfx/javafx-maven-plugin#58. IMO, if we're going to need the class path to do that, I wouldn't bother with the module path in the first place. |
@HGuillemet BTW, could you try to update the ModiTect plugin to 1.0.0.RC1 and make sure there's no issues with the new version? |
module path is usually built automatically by maven, but why not. We would need to replace the
Remember that modular app cannot read classes from the classpath, so moving classes to classpath just exclude the option to run modular apps. The Issue and PR you are linking doesn't involve anyone "official". javafx uses a slighlty different approach : they have also, for instance, both artifacts javafx-graphics-14 and javafx-graphics-14-linux. |
Done. No issue found. |
Right, by default, it's either all or nothing. If we can't remove them on demand, then I suppose the best we can do is force people to add them on demand.
How would that help? The problem is with artifacts for OpenCV, FFmpeg, etc, not JavaCV.
Why? That limitation is quite severe. Like I said, if we have to fall back on the class path to get it working, I don't see the point of using the module path at all, so let's try to figure out something else. |
Hm. I'm not sure what the list of modules should look like depending of what parst of java vc I'm using.. Do I need to add all platforms? The app is a desktop application so it must be as small as possibe. Modules are note required they are just a nice to have if it's not too much pain |
Ok, so you should probably not use the "-platform" artifacts anyway. As long as you don't get any errors, you don't need those modules that you're not adding. |
The problem is with the
I agree. |
Right, but that has nothing to do with JavaCV. We can do all that at the level of OpenCV, FFmpeg, etc. If you know of a way to generate those |
Or alternatively, a Maven extension, which would also allow us to define the target platforms in the /cc @maxsenft |
Looks like ModiTect is also available for Gradle: |
After some more thought, here is what I'm suggesting:
To illustrate this, I have updated the sample project stitching-jlink (PR) Here are the list of modules included in the jlink image in the 3 cases mentioned above:
Nothing needs to be changed to presets or javacpp for this to work. I know 3 maven plugins that can run jlink: moditect, jlink and javafx. The jlink goal of moditect doesn't use maven dependencies to build the module path, it must be populated manually, which is cumbersome and error-prone. We could suggest the author to fix this. The jlink plugin constructs the module path from all maven dependencies. That's not what we want because of the In order to generate the module-info according to That said, the sample program does not work for some independent reason i didn't investigate:
There are also spurious warnings about not finding What do you think ? |
Ok, but ideally one would assume that the module path and graph could just be automatically adjusted to whatever Maven modules the user gave to the build...
maven-jlink-plugin seems abandoned and if javafx-maven-plugin works better for the purpose of the sample project, meh, sure, why not. Ideally, a general plugin like ModiTect should implement all that and JavaFX should then depend on it, but JavaFX is OpenJDK, which can't depend on anything external anyway so it's probably a lost cause, but maybe I'm mistaken, @johanvos? Do you think the guys at JavaFX could contribute their code to ModiTect?
We can use JavaCPP for this. It returns that value as
That looks like an issue with your OpenCL driver... ?
That just means javacpp-platform is missing somewhere, see issues #1305 and bytedeco/javacpp#393 for details.
I'm not convinced that we're getting anywhere because we still have to list all the modules manually in the |
For the module path, yes, that's what maven-jlink plugin and javafx plugin do (the javafx plugin in a smarter way). But we cannot automatically generate the module-info of the user, there are information there we cannot guess: the name of the module, what it exports, opens, which dependencies are transitive... People building JPMS app should be used to write their module-info in addition to their artifact dependencies anyway.
Yes there is a lot in the javafx maven plugin that has nothing to do with javafx that could be in moditect or directly in maven.
Right, but the normal user does't need the javacpp maven plugin. and using the build mojo for just 1 line of Java (
That was a strange locale problem. Running with LANG=C solved the issue in my case.
Shouldn't all the preset-platform have a maven and module dependency towards javacpp-platform ?
Yes, see above. |
The javafx-maven-plugin is being updated. To sum up, users of javacpp presets in JPMS applications will have to:
This solution should also avoid the need to add native modules for JavaCV. They will still have the option to explicitly add the native module (eg with However we need to change the module-info of all Am I overlooking some details ? |
Sounds good! Let's use "requires static" just for good measure. :) Thanks!! |
@HGuillemet When javafx-maven-plugin gets updated, please also update opencv-stitching-jlink! Thank you very much |
@HGuillemet Any news?? |
Ok, that PR has finally been merged. @HGuillemet Could you update the sample project and let's see what that looks like? |
Unfortunately this commit only adds the option to populate the module path with maven dependencies. The required option to add the maven dependencies to the jlink image has been forked in another issue. So currently the |
@HGuillemet It should now work for @jkolobok's use case though right? @jkolobok Can you give it a try with the new version of javafx-maven-plugin? |
We first need to replace the |
Didn't you already do that in pull bytedeco/javacpp-presets#900? |
Yes sorry, it's in javacpp.platform then that the static is missing. |
Sure, please fix whatever needs fixing. Thanks! |
@HGuillemet Thanks! @jkolobok Please give it a try with the snapshots: http://bytedeco.org/builds/ |
Ok, JavaCV 1.5.5 has been released with all the fixes, and I think we've done all that we can do on this end. @HGuillemet Would you know if javafx-maven-plugin now supports everything we need as well? |
It does not, the useful PR doesn't seem like a priority there :( |
@HGuillemet Sorry about the lack of progress on openjfx/javafx-maven-plugin#109 -- I'll check that. |
The same issue seems to be happening with javafx-gradle-plugin as well, see issue #1754. @spectacularcrackers Thanks for reporting! |
I'm also getting this error on my project "Brobot":
Brobot uses Gradle 8.5 and Java 21. It is open-source and is found at https://github.com/jspinak/brobot. The build.gradle file is at https://github.com/jspinak/brobot/blob/main/library/build.gradle. I tried to solve the problem by including the openblas dependency in my build.gradle file and adding the .jar directly to the classpath with IntelliJ, but neither worked. |
Please set the "org.bytedeco.javacpp.logger.debug" system property to "true" to get more information on the console. |
@jspinak I don't see any dependencies on javacv-platform in your build.gradle file |
I have implementation group: 'org.bytedeco', name: 'javacv', version: '1.5.10'. This was working for me fine until this past week when I added database functionality. I made a number of updates to versions and other changes, too many to trace back to the point where JavaCV was working. |
Well whatever the reason why it was working before is irrelevant, it shouldn't have been working. Add a dependency on javacv-platform and it will work again |
Thanks, it's working! Btw, your 2-second response time was very impressive, I usually don't get responses in live conversations that fast :D |
java 11
macos 10.14.6
Sample project:
javafxsample.zip
Workaround - remove module-info.java.. and it starts working...
The text was updated successfully, but these errors were encountered: