vmagnin / gtk-fortran

A GTK / Fortran binding, and its documentation in the Wiki tab.
GNU General Public License v3.0
256 stars 43 forks source link

With Intel ifort/ifx, gtkbuilder, gtkbuilder2 and gtkf-sketcher could not open gtkbuilder.glade #236

Open vmagnin opened 3 years ago

vmagnin commented 3 years ago

Describe the bug When gtk-fortran is built with ifort, gtkbuilder, gtkbuilder2 and gtkf-sketcher don't work and just print that error: Could not open gtkbuilder.glade

Your system:

Additional context No problem with gfortran.

vmagnin commented 3 years ago

Under MSYS2/Windows 10, and compiled with gfortran, gtkbuilder don't work and prints the same message. But gtkbuilder2 and gtkf-sketcher have no problem, probably because they contain the GCC$ ATTRIBUTES DLLEXPORT.

vmagnin commented 3 years ago

gtkbuilder.f90 has been removed from the gtk4 branch, as it is now a duplicate of gtkbuilder2.f90 (they were using two different GTK 3 functions, removed in GTK 4).

vmagnin commented 3 years ago

Same problem with GTK 4.4 and ifort 2021.4.0

vmagnin commented 3 years ago

After replacing gtk_builder_add_from_file() by gtk_builder_new_from_file(), the ifort 2021.4.0 error message is:

(process:24055): Gtk-ERROR **: 18:43:29.082: failed to add UI from file gtkbuilder.glade: No function named `hello`.
Trappe pour point d'arrêt et de trace (core dumped)

although there is a subroutine hello(widget, gdata ) bind(c) in the code.

https://docs.gtk.org/gtk4/class.Builder.html

vmagnin commented 2 years ago

Same error message now with GTK 4.6.2: GFortran 12.0.1 in Fedora Rawhide, GFortran 11.2.0 in FreeBSD 13.

[osboxes@localhost examples]$ ./gtkbuilder2

(process:14648): Gtk-ERROR **: 14:56:45.953: failed to add UI from file gtkbuilder.glade: No function named `hello`.

Program received signal SIGTRAP: Trace/breakpoint trap.

Backtrace for this error:
#0  0x7f0a97623a22 in ???
#1  0x7f0a97622bb5 in ???
#2  0x7f0a97242a2f in ???
#3  0x7f0a9799bd80 in ???
#4  0x7f0a979957f0 in ???
#5  0x7f0a97995a41 in ???
#6  0x7f0a97ed616f in ???
#7  0x4013f7 in gtkbuilder
    at /home/osboxes/gtk-fortran/examples/gtkbuilder2.f90:95
#8  0x401496 in main
    at /home/osboxes/gtk-fortran/examples/gtkbuilder2.f90:86
Trace/breakpoint trap (core dumped)

Line 86 is:

  use handlers

Line 95 is:

builder=gtk_builder_new_from_file("gtkbuilder.glade"//c_null_char)
vmagnin commented 2 years ago

But it works under MSYS2/Windows 10, with GFortran 11.2.0 and GTK 4.6.2.

vmagnin commented 2 years ago

No problem with GTK 4.6.3 and GFortran 12.0.1 in latest Fedora Rawhide.

vmagnin commented 2 years ago

Same problem with ifx 2022.1.0 20220316 ; gtk-fortran 4.2.1, GTK 4.6.3

vmagnin commented 2 years ago

The same error message occurs under MSYS2/Windows 10 if I remove the !GCC$ ATTRIBUTES DLLEXPORT :: attributes in gtkbuilder2.f90, and use GFortran to build it.

vmagnin commented 2 years ago

For Intel Fortran, under Windows we should use: !DIR$ ATTRIBUTES DLLEXPORT :: object [ , object ] ... https://www.intel.com/content/www/us/en/develop/documentation/fortran-compiler-oneapi-dev-guide-and-reference/top/language-reference/a-to-z-reference/a-to-b/attributes/attributes-dllexport-and-dllimport.html

vmagnin commented 2 years ago

Ubuntu 22.04 with GTK 4.6.6 and ifx (IFORT) 2022.1.0 20220316:

$ ./gtkbuilder2

(process:22056): Gtk-ERROR **: 09:29:25.298: failed to add UI from file gtkbuilder.ui: No function named `hello`.

$ gtk4-builder-tool preview gtkbuilder.ui
No function named `hello`.
vmagnin commented 1 year ago

Idem with GTK 4.8.1, ifx 2023.0.0, Ubuntu 22.10.

$ readelf --wide --syms  ./gtkbuilder2 | grep hello
...
Symbol table '.symtab' contains 917 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
...
   818: 0000000000405270    81 FUNC    GLOBAL DEFAULT   16 hello
...
vmagnin commented 1 year ago

May be related to: https://stackoverflow.com/questions/70298845/gi-repository-glib-error-gtk-builder-error-quark-no-function-named-btnprocess

vmagnin commented 1 year ago

This issue is also discussed here: https://fortran-lang.discourse.group/t/a-long-standing-bug-in-a-gtk-fortran-example-with-intel-compilers/5734

vmagnin commented 6 months ago

Could it be because GTK is not built with an Intel compiler?

vmagnin commented 6 months ago

Or should we use a specific Intel compiler flag?