Using PackageCompiler.jl with Gtk.jl

Hi, I’m trying to build a gui using julia.
I am running this on ubuntu 20.04

I have a module called TEST
TEST/src/TEST.jl code:

module TEST
using Gtk

export real_main, julia_main

const win = Ref{GtkWindow}()
const img = Ref{GtkImage}()

function julia_main()::Cint
    try
        real_main()
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
    return 0
end

function real_main()
    cd(@__DIR__)
    println(abspath("../data/logo.png"))

    win[] = GtkWindow("Crystal Chess", 800, 800)
    img[] = GtkImage(abspath("../data/logo.png"))

    push!(win[], img[])
    showall(win[])

    readline()
end
end # module

I got this error after running the compiled file

(TEST:15355): Gtk-WARNING **: 20:36:36.922: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
**
Gtk:ERROR:../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/16x16/status/image-missing.png: Unrecognized image file format (gdk-pixbuf-error-quark, 3)

signal (6): Aborted
in expression starting at none:0
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
g_assertion_message at /workspace/srcdir/glib-2.59.0/glib/gtestutils.c:2878
g_assertion_message_error at /workspace/srcdir/glib-2.59.0/glib/gtestutils.c:2993
ensure_surface_for_gicon at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkiconhelper.c:494
gtk_icon_helper_load_surface at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkiconhelper.c:566
gtk_icon_helper_ensure_surface at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkiconhelper.c:603
gtk_icon_helper_ensure_surface at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkiconhelper.c:647 [inlined]
_gtk_icon_helper_get_size at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkiconhelper.c:662
gtk_image_get_content_size at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkimage.c:1716
gtk_css_custom_gadget_get_preferred_size at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkcsscustomgadget.c:124
gtk_css_gadget_get_preferred_size at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkcssgadget.c:683
gtk_image_get_preferred_height_and_baseline_for_width at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkimage.c:1948
gtk_widget_query_size_for_orientation at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:215
gtk_widget_compute_size_for_orientation at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:399
gtk_widget_get_preferred_height at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:527
gtk_window_get_preferred_height at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkwindow.c:8969
gtk_widget_query_size_for_orientation at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:219
gtk_widget_compute_size_for_orientation at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:399
gtk_widget_get_preferred_height_and_baseline_for_width at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:642
_gtk_widget_get_preferred_size_and_baseline at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtksizerequest.c:703
gtk_window_compute_hints at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkwindow.c:10286 [inlined]
gtk_window_compute_configure_request at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkwindow.c:9598
gtk_window_move_resize at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkwindow.c:9807
_g_closure_invoke_va at /workspace/srcdir/glib-2.59.0/gobject/gclosure.c:873
g_signal_emit_valist at /workspace/srcdir/glib-2.59.0/gobject/gsignal.c:3300
g_signal_emit at /workspace/srcdir/glib-2.59.0/gobject/gsignal.c:3447
gtk_container_idle_sizer at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkcontainer.c:2065
_g_closure_invoke_va at /workspace/srcdir/glib-2.59.0/gobject/gclosure.c:873
g_signal_emit_valist at /workspace/srcdir/glib-2.59.0/gobject/gsignal.c:3300
g_signal_emit at /workspace/srcdir/glib-2.59.0/gobject/gsignal.c:3447
gdk_frame_clock_paint_idle at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gdk/gdkframeclockidle.c:428
gdk_threads_dispatch at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gdk/gdk.c:777
g_timeout_dispatch at /workspace/srcdir/glib-2.59.0/glib/gmain.c:4680
g_main_dispatch at /workspace/srcdir/glib-2.59.0/glib/gmain.c:3191 [inlined]
g_main_context_dispatch at /workspace/srcdir/glib-2.59.0/glib/gmain.c:3856
g_main_context_iterate at /workspace/srcdir/glib-2.59.0/glib/gmain.c:3929
g_main_loop_run at /workspace/srcdir/glib-2.59.0/glib/gmain.c:4125
gtk_main at /workspace/srcdir/gtk+-3.24.11/build-gtk/../gtk/gtkmain.c:1323
#237 at /home/charlie/.julia/packages/Gtk/X7HfN/src/events.jl:2
unknown function (ip: 0x7f13ba8ffffc)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2159 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
g_sigatom at /home/charlie/.julia/packages/Gtk/X7HfN/src/GLib/signals.jl:176
gtk_main at /home/charlie/.julia/packages/Gtk/X7HfN/src/events.jl:1
jfptr_gtk_main_15635 at /home/charlie/OneDrive/CrystalChessPackage/TESTCompiled/bin/TEST.so (unknown line)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2145 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2323
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1700 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:687
unknown function (ip: (nil))
Allocations: 21704548 (Pool: 21698794; Big: 5754); GC: 24
Aborted (core dumped)

This should be reported as an issue at some of the packages. What do you think @giordano is that a PackageCompiler.jl issue, a Gtk.jl issue or an issue with BB?

I’d first try to asses whether this works without PackageCompiler.

1 Like

Sorry for replying so late!
I forgot to add that I get this warning no matter if I compiled it or not:

Gtk-Message: 21:10:46.965: Failed to load module "canberra-gtk-module"
Gtk-Message: 21:10:46.968: Failed to load module "canberra-gtk-module"

This works when not compiled but doesn’t work when it is.

Those warnings are totally harmless, you can ignore them

Maybe @kristoffer.carlsson has some ideas?

Those are harmless but still annoying. If you search it online you’ll see how to fix it. It just means you are missing some gtk pieces that it wants.

1 Like

Can you tell us how to fix the warnings? That would be awesome, there is also an issue open in Gtk.jl

Like I said, I just googled the error message. For the error message above, it seems that doing

sudo apt install libcanberra-gtk-module libcanberra-gtk3-module

might fix the issue. When I got the error messages, it was actually complaining about a different module, so I think there must be something related to the system installation which likely differs across distros.

1 Like