Closed binarydigitz01 closed 2 years ago
Here is my $LD_LIBRARY_PATH
/nix/store/ans0zi3b9k02ikks810np7i87j5vvsip-gobject-introspection-1.74.0/lib:/nix/store/5rj03qmq4i4vb872r3bb0vhsk2xcv57m-glib-2.74.1/lib:/nix/store/ry57by1j7yfnhv6iij7cibd0n7alk5sw-gtk4-4.8.2/lib:/nix/store/ry57by1j7yfnhv6iij7cibd0n7alk5sw-gtk4-4.8.2/bin
@binarydigitz01 Can you provide some detailed information, such as the call stack where the error occurred? You may try this example in Python to test out whether gobject-introspection
works fine in your system.
Stack Trace :
0: ((LAMBDA (&REST GIR::ARGS-IN) :IN GIR::BUILD-FUNCTION) "org.bohonghuang.cl-gtk4-example" 0)
1: (GTK4.EXAMPLE:SIMPLE)
2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (GTK4.EXAMPLE:SIMPLE) #<NULL-LEXENV>)
3: (EVAL (GTK4.EXAMPLE:SIMPLE))
Sure I'll check out the python example
I checked it out, and the python example works as expected.
@binarydigitz01 Can you print out the value of (gir::repository-get-search-path)
after loading cl-gtk4
?
("/nix/store/fhbrxggdwy28dzbcqxf25slxrp1vfk96-gdk-pixbuf-2.42.10/lib/girepository-1.0"
"/nix/store/dinn3b9mh7d0wcwhkyqyqmz3lw793glh-graphene-1.10.8/lib/girepository-1.0"
"/nix/store/iwr05lr9cnwnpd5p3h4v5cj7wdij0rsy-harfbuzz-5.2.0/lib/girepository-1.0"
"/nix/store/l49qnb6j4516dxjjja12zmq4ydldmmak-pango-1.50.11/lib/girepository-1.0"
"/nix/store/5adcsapgip7glpwibkqly9bh8q6fgdl7-gsettings-desktop-schemas-43.0/lib/girepository-1.0"
"/nix/store/ry57by1j7yfnhv6iij7cibd0n7alk5sw-gtk4-4.8.2/lib/girepository-1.0"
"/nix/store/ans0zi3b9k02ikks810np7i87j5vvsip-gobject-introspection-1.74.0/lib/girepository-1.0"
"/nix/store/ans0zi3b9k02ikks810np7i87j5vvsip-gobject-introspection-1.74.0/lib/girepository-1.0")
@binarydigitz01 Sorry, I'm not very familiar with the Nix-like system. Can you find the file like /usr/share/gir-1.0/Gtk-4.0.gir
and check out the field shared-library
in it? In my machine, it looks like this:
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="Gdk" version="4.0"/>
<include name="Gsk" version="4.0"/>
<package name="gtk4"/>
<c:include name="gtk/gtk.h"/>
<namespace name="Gtk"
version="4.0"
shared-library="libgtk-4.so.1"
c:identifier-prefixes="Gtk"
c:symbol-prefixes="gtk">
...
Can you tell me what library does install that file? Having trouble finding it myself
@binarydigitz01 It belongs to gtk4
in my system.
I can't really seem to find it, let me go talk to other nixos users, and I'll get back to you
I have successfully loaded the library by setting the LD_LIBRARY_PATH to all the libraries mentioned. The $LD_LIBRARY_PATH also contains the location of gtk4/lib directory
@binarydigitz01 All right. You can also try adding the paths to these libraries to cffi:*foreign-library-directories*
before loading cl-gtk4
instead of setting up LD_LIBRARY_PATH
. To recompile the library, you may need to clean up the cache directory of the Lisp implementation first.
Finally found it. It's at /nix/store/q7rwmj163mk4dkar5wcbkdmha71518jq-gtk4-4.8.2-dev/share
, the field shared-library
is: /nix/store/ry57by1j7yfnhv6iij7cibd0n7alk5sw-gtk4-4.8.2/lib/libgtk-4.so.1
it seems that that the gtk4-dev directory isn't found by cffi...
it seems that that the gtk4-dev directory isn't found by cffi...
Have you tried resetting LD_LIBRARY_PATH
and adding the paths to libgobject-2.0.so
and libgirepository-1.0.so
into cffi:*foreign-library-directories*
? Theoretically, gtk4-dev
is not mandatory for this library, and /nix/store/ry57by1j7yfnhv6iij7cibd0n7alk5sw-gtk4-4.8.2/lib/libgtk-4.so.1
seems existent in your system and can be loaded by gobject-introspection in Python, so it should work without problem.
I tried setting cffi:foreign-library-directories, but it didn't work. It seems this is more of a cffi isuue than cl-gtk4. Could you please tell me how exactly cffi works, and what all does cl-gtk4 need, so i could ask the devs of cffi as well?
@binarydigitz01 Sure. All the cffi foreign libraries required by cl-gtk4
are defined in cl-gobject-introspection:
(eval-when (:compile-toplevel :load-toplevel :execute)
(cffi:define-foreign-library gobject
(:darwin "libgobject-2.0.dylib")
(:unix (:or "libgobject-2.0.so.0" "libgobject-2.0.so"))
(:windows "libgobject-2.0-0.dll")
(t "libgobject-2.0"))
(cffi:define-foreign-library girepository
(:darwin "libgirepository-1.0.dylib")
(:unix (:or "libgirepository-1.0.so" "libgirepository-1.0.so.1"))
(:windows (:or "libgirepository-1.0.dll" "libgirepository-1.0.0.dll"
"libgirepository-1.0-1.dll"))
(t "libgirepository-1.0")))
where the shared library names could be replaced with the absolute paths to them in your system and these libraries are loaded by cffi
. Other shared libraries required by GObject-based library like GTK4 is loaded by libgirepository
, not by cffi
, and the invocation to GTK4 function is delegated to libgirepository
too. This library could be loaded without problem, which means cffi
can load libgirepository
and query the functions in GTK4, but it failed to call these functions through it. So the error may occur in libgirepository
, instead of cffi
.
Sorry, I believe i forgot to mention the complete error: Could not locate gtk_application_new: /nix/store/v6szn6fczjbn54h7y40aj7qjijq7j6dc-glibc-2.34-210/lib/libm.so.6: version `GLIBC_2.35' not found (required by /nix/store/63d8pp6a9i2p9bmsd0n1dvsqslmf20dn-cairo-1.16.0/lib/libcairo.so.2)
It seems that cairo is the one throwing the error, not cffi. So it's a problem on my end.
I have glibc-2.74.1, not 2.35, so that might be an issue
Yeah that was the issue TYSM for your time!
I have glibc-2.74.1, not 2.35, so that might be an issue
Maybe you are confusing glibc
and glib2
. The latter serves as a fundamental library for GObject-based libraries, while the former is the basis for your system to run
hmmm ig so, but actually i was pulling libraries from unstable repo, switching to stable seems to have to fixed it for me...
Hi I'm new to common-lisp. I'm using nixos, so the standard positions of libraries vary. I have successfully loaded the library by setting the LD_LIBRARY_PATH to all the libraries mentioned. The $LD_LIBRARY_PATH also contains the location of gtk4/lib directory, so it should have no problem finding gtk functions. Any help please?