Skip to content

Conversation

@florianober
Copy link
Contributor

@florianober florianober commented May 2, 2025

Hi @vmagnin,

i just realised that gtk-fortran isn't compiling with the new gfortran 15, because gfortran is using new iso_c_binding as part of Fortran 2023. Included is a function (f_c_string) which converts fortran strings to c strings. This function is in conflict with the interface defined in the gtk-sup.f90.
As far as i can see, there is only one module (gtk-hl-dialog.f90) using this subroutine. Thus, i switched to the second interface defined in gtk-sup.f90 as well (convert_f_string) and removed the f_c_string interface.

If you don't like this, you could also add -std=f2018 as compiler flag for the moment.

Kind regards :)
Florian

@vmagnin
Copy link
Owner

vmagnin commented May 2, 2025

Thanks Florian for reporting.

I had similar problems at first but they disappeared.

Can you try first to delete and recreate your build directory? I know that with GFortran 15 the .mod files format has been modified and it can cause such problems if there are mix GFortran 14 & 15 mod files in the build.

@florianober
Copy link
Contributor Author

Hi,

yes i did that. gtk-fortran ist not compiling on arch and even when using msys2 ucrt64 (gfortran 15.1)

@vmagnin
Copy link
Owner

vmagnin commented May 2, 2025

OK. No problem with GFortran 15.1.1 under Fedora 42.

I will try soon on UCRT64.

I wonder if it could be related to warnings I had obtained with Intel ifx about those string functions. I have therefore also opened that issue:
https://github.com/vmagnin/gtk-fortran/issues/296

@florianober
Copy link
Contributor Author

florianober commented May 2, 2025

ja, i think this is the same issue. its strange that it is working on Fedora. maybe they use other compilerflags/defaults ?

@vmagnin
Copy link
Owner

vmagnin commented May 2, 2025

I don't know.

But I have just successfully build the latest gtk3 and gtk4 branches with GFortran 15.1.0 under MSYS2/Windows 10 (UCRT64).

No problem so far on my side. I will look if I have other systems in virtual machines with GFortran 15.

@vmagnin
Copy link
Owner

vmagnin commented May 2, 2025

I had posted on Monday that problem in Fedora 42:

[ 23%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-button.f90.o
/home/osboxes/gtk-fortran/src/gtk-hl-dialog.f90:41:6:

   41 |   use gtk_sup
      |      1
......
  289 |        call f_c_string(name, string)
      |                                    2
Error: ‘f_c_string’ at (1) has a type, which is not consistent with the CALL at (2)

$ gfortran --version
GNU Fortran (GCC) 15.1.1 20250425 (Red Hat 15.1.1-1)

But soon it disappeared (the same day). I don't know if I have made a make clean or something like that. No explanation...

@florianober
Copy link
Contributor Author

florianober commented May 2, 2025

yes, this is the error i always get regardless if i use ucrt64 with gfortran 15.1 or Arch linux with gfortran 15.1.1.
I just made a new msys2 installation on my wifes computer .... , but the error comes again. However, i noticed i don't compile the way it is written in the install.md file.

I do (there is no build directory ;) :

cmake -B build
cmake --build build

if i follow you instructions i get:

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran
$ mkdir build3

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran
$ cd build3

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran/build3
$ cmake ..
-- Building for: Ninja
-- The Fortran compiler identification is GNU 15.1.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: D:/msys64/ucrt64/bin/gfortran.exe - skipped
-- Building gtk-3-fortran 3.24.49
-- Based on GTK 3.24.49 and GLib 2.84.1
-- GNUInstallDirs: C:/Program Files (x86)/gtk-fortran lib include bin share share/man
-- System: Windows 10.0.19045 AMD64
-- Compiler: GNU 15.1.0 D:/msys64/ucrt64/bin/gfortran.exe
-- Build type is: release
-- Compilation flags:  -pthread -O3 -mtune=native -march=native
-- Found PkgConfig: D:/msys64/ucrt64/bin/pkg-config.exe (found version "2.3.0")
-- Checking for module 'gtk+-3.0'
--   Found gtk+-3.0, version 3.24.49
-- Checking for module 'plplot-fortran'
--   Found plplot-fortran, version 5.15.0
-- Checking for module 'plplot'
--   Found plplot, version 5.15.0
-- Configuring done (2.2s)
-- Generating done (0.4s)
-- Build files have been written to: D:/msys64/home/Lena Ober/gtk-fortran/build3

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran/build3
$ make
make: *** No targets specified and no makefile found.  Stop.

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran/build3

@vmagnin
Copy link
Owner

vmagnin commented May 2, 2025

I always do:

$ cd build
$ cmake -D CMAKE_BUILD_TYPE=debug ..
$ make

Is this a Ninja related problem like in this issue? #292

On my side I don't use Ninja.

@florianober
Copy link
Contributor Author

ok, this solves to issue above, but nonetheless, if i use the Makefiles generator its reporting the error too:

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran
$ rm -fr build3

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran
$ cmake -B build3 -G "MinGW Makefiles"
-- The Fortran compiler identification is GNU 15.1.0
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: D:/msys64/ucrt64/bin/gfortran.exe - skipped
-- Building gtk-3-fortran 3.24.49
-- Based on GTK 3.24.49 and GLib 2.84.1
-- GNUInstallDirs: C:/Program Files (x86)/gtk-fortran lib include bin share share/man
-- System: Windows 10.0.19045 AMD64
-- Compiler: GNU 15.1.0 D:/msys64/ucrt64/bin/gfortran.exe
-- Build type is: release
-- Compilation flags:  -pthread -O3 -mtune=native -march=native
-- Found PkgConfig: D:/msys64/ucrt64/bin/pkg-config.exe (found version "2.3.0")
-- Checking for module 'gtk+-3.0'
--   Found gtk+-3.0, version 3.24.49
-- Checking for module 'plplot-fortran'
--   Found plplot-fortran, version 5.15.0
-- Checking for module 'plplot'
--   Found plplot, version 5.15.0
-- Configuring done (2.1s)
-- Generating done (0.7s)
-- Build files have been written to: D:/msys64/home/Lena Ober/gtk-fortran/build3

Lena Ober@DESKTOP-ACF18P4 UCRT64 ~/gtk-fortran
$ cmake --build build3
[  1%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gdk-pixbuf-auto.f90.obj
[  2%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/api_compatibility.f90.obj
[  3%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/atk-auto.f90.obj
[  3%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/cairo-auto.f90.obj
[  4%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gdk-auto.f90.obj
[  5%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/glib-auto.f90.obj
[  6%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk.f90.obj
[  6%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-sup.f90.obj
[  7%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gdk-pixbuf-hl.f90.obj
[  8%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gdkevents-auto.f90.obj
[  9%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-draw-hl.f90.obj
[ 10%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-accelerator.f90.obj
[ 11%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-assistant.f90.obj
[ 11%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-misc.f90.obj
[ 12%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-button.f90.obj
[ 13%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-container.f90.obj
[ 14%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-entry.f90.obj
[ 15%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-chooser.f90.obj
[ 16%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-combobox.f90.obj
[ 17%] Building Fortran object src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-dialog.f90.obj
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  280 |        call f_c_string(name, string)
      |                                    2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  286 |        call f_c_string(license, string)
      |                                       2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  294 |        call f_c_string(comments, string)
      |                                        2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  299 |        call f_c_string(website, string)
      |                                       2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  304 |        call f_c_string(website_label, string)
      |                                             2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  309 |        call f_c_string(translators, string)
      |                                           2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  314 |        call f_c_string(copyright, string)
      |                                         2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  319 |        call f_c_string(version, string)
      |                                       2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  327 |           call f_c_string(authors(i), string)
      |                                             2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  340 |           call f_c_string(documenters(i), string)
      |                                                 2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
D:\msys64\home\Lena Ober\gtk-fortran\src\gtk-hl-dialog.f90:50:6:

   50 |   use gtk_sup
      |      1
......
  353 |           call f_c_string(artists(i), string)
      |                                             2
Error: 'f_c_string' at (1) has a type, which is not consistent with the CALL at (2)
mingw32-make[2]: *** [src\CMakeFiles\gtk-fortran_object.dir\build.make:344: src/CMakeFiles/gtk-fortran_object.dir/gtk-hl-dialog.f90.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:363: src/CMakeFiles/gtk-fortran_object.dir/all] Error 2
mingw32-make: *** [Makefile:165: all] Error 2

@florianober
Copy link
Contributor Author

florianober commented May 2, 2025

ok, i see why there is no error when you are compiling:
your debug mode sets the fortran std to f2008:

-- Compilation flags:  -g -pthread -Wall -Wextra -pedantic -std=f2008 -Wtabs -fcheck=all -fbacktrace -Wno-unused-dummy-argument

this is similar to the workaround i suggested in the first post

@vmagnin
Copy link
Owner

vmagnin commented May 3, 2025

I will also put the -std08 Intel ifx flag into -cmake/DefaultFlags.cmake and add a comment into the Wiki doc.
And I will do the same thing in the gtk4 branch (where two more examples are using f_c_string()).

@florianober
Copy link
Contributor Author

florianober commented May 3, 2025

i don't know, if i would fix the fortran standard. If you want to, you should do it for the debug and for the release build mode too for both Compiler.
I personally would remove these compiler flags completely or fix the Standard in the release build only, to ensure the compilation of the library.

@vmagnin
Copy link
Owner

vmagnin commented May 3, 2025

Interesting, @florianober .
I have opened a discussion for that subject: #297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants