Could not load library libgtk-4.so.1 #324
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi#324
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm trying to run the example in https://java-gi.org/usage/, but I'm getting the following exception:
I'm using
-Djava.library.path=/home/<stuff_here>/_libsand the folder_libscontainslibgtk-4.so.1.I can even successfully read its contents using this code:
correctly outputs
10908688bytes, andlibgtk-4.so.1is 10,9 MB.What might be my issue?
Thank you for trying out Java-GI!
Gtk is much more than just the file
libgtk-4.so.1. How did you install Gtk in this location? If you just copied this file, it will not work.If you’re sure that Gtk is installed correctly (for example,
gtk4-demoruns fine), then try running your app with the environment variableLD_DEBUG=libsset. It will print detailed logging from the dynamic linker that will help you find the cause.My IDE is installed via flatpak and doesn't have access to
/usr/lib64, so I copied the folder to a location the IDE can access (_libs).What files does Java-GI need to work?
Also, I just want to mention that I know a lot about Java but absolutely nothing about system libraries, so sorry if that question seems stupid
That's never going to work. GTK is far too complicated to get it working by manually copying files.
I am afraid you will have to install the IDE in another way.
How exactly does it work when an app bundles gtk? Doesn't it include the
.sofiles and could I do something similar to that?It's not really necessary to bundle Gtk on most Linux systems, because it's usually preinstalled. A flatpak app would use the GNOME runtime; you can see how that works in combination with java-gi in here. You can edit that project in a flatpak-installed IDE, but you can't run it from the IDE. (As a workaround, you could build and run the flatpak every time, but it's not a nice workflow.)
On Windows, all Gtk libraries and executables, including its dependencies, can be installed in one place, so it's relatively easy to bundle it. You can download the necessary files here.
I'm not sure about how this all works on macOS.
My advice is to build your app in an IDE that can use your system's Gtk libraries, so you can build and run your app directly from the IDE. Alternatively, you can install the IDE and Gtk in a Distrobox container; that's what I do.
For distribution, you can use the app-template I linked above, to create a flatpak based on the GNOME runtime.
Thanks for all the useful information!
I've solved the problem by letting my IDE talk to
org.freedesktop.Flatpakand using this gradle task I made:Using this I can spawn java outside of the sandbox, while retaining all the benefits of a sandboxed IDE. It's probably not the best solution, but it works. I'll also make sure to look at your template for creating Flatpak apps.
Thanks for all the help!
Hi @OutCraft-Mods,
I'm in the same situation as you, and I tried to adapt your solution to my setup, but I struggle. Currently, I have successfully enabled access to flatpak-spawn, and my JDK, but it's not finding my main class.
I suspect it's because of the following line not correctly configured for my setup :
Could you elaborate on how you came up with it, so I can maybe adapt it to my setup which might be a bit different ?
Thanks a lot in advance 🙏
Hi Ombrelin, if you're getting issues with this line, you should check where your
.gradledirectory is located. My IDE saves it in~/.var/app/com.jetbrains.IntelliJ-IDEA-Community/.gradle/, so I'm replacing the path with it.Do you know where your gradle directory is stored? If not, I'd recommend simply searching for "gradle" from your home directory.
I hope I could help!
Hi @OutCraft-Mods , thanks a lot for your answer.
Indeed I have no
~/.var/app/com.jetbrains.IntelliJ-IDEA-Community/.gradle/, I just get a~/.gradlewhen running the search you suggest, which I'm not sure is the right directory 🤔 because it doesn't feel related to my flatpak IntelliJ (I have a/home/arsene/.var/app/com.jetbrains.IntelliJ-IDEA-Communitythough, but it contains no.gradle)