loadLibrary order causes javagi.path to be ignored #216
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#216
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?
In
GLib,libgobjectis loaded beforelibglib, even though it depends on it.As a consequence, the JVM tries to load
libglibby itself from the systemPATH(notjava.library.path!), which fails, causing startup to fail.This also isn't the only dependency of this kind.
It is possible to load these libraries manually ahead of javagi in this order, which lets the application start:
Generated via this code
This really isn't an issue on Linux where this property probably isn't used by anyone.
On Windows however, apps probably want to ship their own GTK binaries (ideally packaged neatly in some maven dependency), which is made quite a bit more difficult by this fact.
We can reverse the ordering of
libgobjectandlibglibin the GLib class, but I don't think it's feasible to load the other libraries (in the right order), because they aren't listed in the gir files. What would you propose? I could add a code example to the documentation to show how to manually load all libraries in the right order (based on your list)?I don't really have a good solution for this.
I have messed about a bit with an approach that covers correctly loading the GTK binaries as well as distributing them in a test project, but that is hardly ready for widespread use.
A self-extracting dependency like what I tried to do there is probably the easiest from the developer perspective and could be provided as an optional module using builds by the windows-gtk script.
However, an installed, production-ready application should really be installing the binaries directly from the installer.
My previous experiment abuses the fact that the executable directory is always part of the library path on Windows, but that required two copies of every library to bridge the gap between these different approaches to loading libraries.
While this gives us installer-managed libraries, it isn't really a good solution since it wastes space and doesn't cover development.
Since these requirements are contradictory, I'm almost at the point of thinking that library loading should be delegated to additional modules, with a suggested default module that effectively does what LibLoad is today (perhaps this one can even be shipped by default?), an additional module that extracts the GTK libraries like in
gtk-repackagedand manually loads them using a known-good load order (this can be discovered mechanically as is done in gtk-repackaged), and a similar module that uses a known path to load the same libraries, so they can be shipped with the installer.This would also leave open the option for user-provided library loading code, which is kind of needed on Windows to support the various ways an application could be installed.
This feels extremely over-engineered, but I honestly don't have a better idea.
I have had an idea for this. Give me a few days and I should have a PR that at least solves this issue (though it won't solve distribution completely)