Skip to content

Failed to build a simple gtk-fortran example: how to link with gtk-4-fortran? #487

@vmagnin

Description

@vmagnin

I have created a small repository with the example I am trying to build as an fpm project:
https://github.com/vmagnin/gtkzero_fpm
It is the gtkzero_gapp.f90 available in the gtk-fortran gtk4 branch: it just opens an empty GTK 4 window. As the original file contains the main program and a handlers module, I have put that module in src/handlers.f90. The main program has been renamed: app/main.f90.

My fpm version is 0.2.0 alpha. I have tried adding link = "gtk-4-fortran" in the [build] section of the fpm.toml file, but it does not change anything.

$ fpm build --flag '$(pkg-config --cflags --libs gtk-4-fortran)'
Unable to find source for module dependency: "gtk" used by "app/main.f90"
ERROR STOP 1

Error termination. Backtrace:
#0  0x7f559b678820 in ???
#1  0x7f559b679379 in ???
#2  0x7f559b67ab02 in ???
#3  0x55e89918f6a5 in __fpm_MOD_cmd_build
        at ././src/fpm.f90:260
#4  0x55e89917944f in MAIN__
        at app/main.f90:26
#5  0x55e89917944f in main
        at app/main.f90:9

Same error if I replace the apostrophes by double quotes.

This is the output of the pkg-config command on my machine:

$ pkg-config --cflags --libs gtk-4-fortran
-rdynamic -mfpmath=sse -msse -msse2 -pthread -I/usr/local/include/gtk-4-fortran -I/usr/include/gtk-4.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Xlinker -R/usr/local/lib -lgtk-4-fortran -lgtk-4 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lvulkan -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0

The gtk-fortran modules are here:

$ ls /usr/local/include/gtk-4-fortran
cairo.mod          g.mod                 gtk_hl_button.mod     gtk_hl_entry.mod     gtk_hl_spin_slider.mod  handlers_gtk_fortran.mod
gdk_events.mod     graphene.mod          gtk_hl_chooser.mod    gtk_hl_infobar.mod   gtk_hl_tree.mod         pango.mod
gdk.mod            gsk.mod               gtk_hl_combobox.mod   gtk_hl_misc.mod      gtk.mod                 plplot_extra.mod
gdk_pixbuf_hl.mod  gtk_draw_hl.mod       gtk_hl_container.mod  gtk_hl.mod           gtk_os_dependent.mod    unix_print.mod
gdk_pixbuf.mod     gtk_hl_assistant.mod  gtk_hl_dialog.mod     gtk_hl_progress.mod  gtk_sup.mod

Metadata

Metadata

Assignees

No one assigned

    Labels

    packagingRelated to porting or packaging a project to fpm

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions