-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Extraction issues with native libraries on macOS and Linux #797
Comments
First of all: FlatLaf automatically extracts native libraries from flatlaf.jar to temporary folders. If you like to ship the FlatLaf native libraries with your application (to avoid loading from temporary folder),
Extracting to
The expected file names for the native libraries are the same as used in flatlaf.jar: They start with Relative paths are relative to the working directory of your application.
Yes, this is usual library naming on macOS and Linux.
To be correct it says: For flatlaf.nativeLibraryPath="system", FlatLaf uses method If you think that flatlaf.nativeLibraryPath="system" does not work, then you've either put the FlatLaf natives to the wrong directory, or they have wrong names, or there is a bug in Java.
Yes, this is because they are immediately deleted after loading. The source code of FlatLaf is freely available. You can simply debug into following method to find out whether or where it is extracted: FlatLaf/flatlaf-core/src/main/java/com/formdev/flatlaf/util/NativeLibrary.java Lines 102 to 154 in eed11d2
For me it works fine. |
Probably my bad explanation, but you appear to have misunderstood some of what I said. No matter, I've got what I need from your response. FYI My confusion about the linux/macos library filenames arose because the files in Maven (where I manually downloaded them from) don't have lib in front of them, and there is no reference to the lib prefix in the documentation. I never thought to just look in the jar file (sorry!). In future if I have an issue I'll check out the source code first rather than wasting your time. Thanks for all the great work you are doing. |
…ports loading native libraries named the same as on Maven central; improved log messages for loading fails (issue #797)
Thanks for your feedback. I've fixed/improved the log messages and the system property docs: FlatLaf/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatSystemProperties.java Lines 174 to 205 in 722dde6
Yes, the Maven native file names do not work with
But there is also no reference to the system property Is there a reason that you want use |
…ports loading native libraries named the same as on Maven central; improved log messages for loading fails (issue JFormDesigner#797)
My reasoning for using Background info: I use My gut feel (based on 40 years experience in IT) is that at some point something may interfere with the extraction. Maybe an AV or other security system doing so deliberately, or by mistake, or just some weird permissions setup or problem on a user's computer. So I'd prefer to have the appropriate library pre-extracted. It also means I can prevent the native libraries from getting into So I manually put the appropriate library alongside all the other native libraries in my app: In Finally, my control-freak/pessimistic nature tells me to explicitly set |
On Windows everything works as expected: The appropriate library is extracted to 'java.io.tmpdir'/flatlaf.temp, and when I use flatlaf.nativeLibraryPath it is picked up from there (or extracted if I deliberately use the wrong path)
On macOS and Linux nothing works as expected and both O/S "fail" in the same way: If I use flatlaf.nativeLibraryPath="." (or any relative path) and whether or not I manually put the native lib there then the flatlaf error message says it can't find the library (using the wrong name!) and says it will extract it. For example on Linux it says "Did not find external library ./libflatlaf-linux-x86_64.so, using extracted library instead". On macOS a similar message appears, again with 'lib' prepended to the library name.
If I then put the library in the correct place and rename it with 'lib' added to the name (e.g. libflatlaf-linux-x86_64.so) then no error message appears and it appears to work okay. So it seems that the code is pre-pending a spurious 'lib' to the library name.
If I use flatlaf.nativeLibraryPath="system" then it doesn't seem to matter if I put the native lib on any of the 'system' paths, or not, it always fails. I always get a flatlaf error message saying e.g. "Did not find external library flatlaf-linux-x86_64.so, using extracted library instead". Note that in this case the 'lib' is not prepended to the library name in the message, but it never seems to pick up the native library no matter where I place it.
Finally, with both Linux and macOS and with all the configurations I've tried, when the error message says it is extracting it (and when I don't use flatlaf.nativeLibraryPath), I've not yet been able to find an extracted library in the entire filesystem, and especially not within java.io.tmpdir. So it doesn't seems to be extracting the library when it fails to find it.
For the Linux/macOS tests I'm using a x64 laptop running the latest Mint, and an Apple M macmini running the latest macOS v14. I'm using the latest Adoptium Java 17 on both systems, and FlatLaf 3.3, and I've repeated every test on each O/S in Eclipse, standalone apps using jars, and standalone apps after using jlink.
The text was updated successfully, but these errors were encountered: