# Gtk-fortran 20.04 released, preparing for GTK 4

**URL:** <https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45>\
**Category:** Announcements\
**Created:** [May 15, 2020, 7:59pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45 "2020-05-15T19:59:03Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 24, 2020, 8:18am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/21 "2020-07-24T08:18:41Z")

</div>

Daunting is the word! GTK is a huge API, a world in itself. I plan in the next months to add more tutorials. Up to now, the program examples were the only way to learn gtk-fortran. But I was inspired by this post: [https://github.com/fortran-lang/stdlib/issues/182](https://github.com/fortran-lang/stdlib/issues/182) about documentation.

Regrettably, it is true there is very few books about GTK. In the Tutorials page, you will find those two books:

- Andrew Krause, [Foundations of GTK+ Development](http://www.apress.com/9781590597934), _Apress_ , 2007, ISBN-13: 978-1-59059-793-4, 630pp.
- David Ashley, Andrew Krause, [Foundations of PyGTK Development - GUI Creation with Python](https://www.apress.com/gp/book/9781484241783), _Apress_ , 2019, ISBN-13: 978-1-4842-4178-3, 563pp.

The first one is excellent, C oriented, but now obsolete (GTK 2). The second one is the GTK 3 version but for Python. Unhappily, I think it is easier to adapt C GTK code to Fortran than Python GTK code (higher level than the original).

For GTK 3, I recommend: [https://www.youtube.com/c/MichaelB-GTK/videos](https://www.youtube.com/c/MichaelB-GTK/videos)  
Michael B. has posted on its channel more than 200 videos on GTK 3 programming (C language)!

Having personally only tested gtk-fortran on Windows 7, have you encountered specific problems (not stated in the documentation) with Windows 10?

---

<div class="post-metadata">

**Author:** ![Pompito](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Pompito](https://fortran-lang.discourse.group/u/Pompito)\
**Post date:** [July 24, 2020, 6:33pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/22 "2020-07-24T18:33:58Z")

</div>

The only issue I found, but solved easily, was when doing `make` after cmake.  
Make tried to compile a fortran source file with a line longer than 132 characters and GFortran (10.1) issued an error, not warning, thus stopping the build.  
I just searched the culprit line and split it with an ampersand and voila.  
I should mention that I did ` wget https://github.com/vmagnin/gtk-fortran/archive/gtk3.tar.gz` instead of pulling with git. I could check which file was later.

The examples I tried (julia, mandelbrot, and some more) were working fine.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 24, 2020, 6:57pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/23 "2020-07-24T18:57:33Z")

</div>

> I could check which file was later.

I am interested to know the culprit. I have never encountered that error.

> The examples I tried (julia, mandelbrot, and some more) were working fine.

😀

---

<div class="post-metadata">

**Author:** ![Pompito](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Pompito](https://fortran-lang.discourse.group/u/Pompito)\
**Post date:** [July 24, 2020, 8:53pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/24 "2020-07-24T20:53:15Z")

</div>

Here is the error:

```auto
[89%] Building Fortran object sketcher/CMakeFiles/gtkf-sketcher.dir/gtkf-sketcher.out.f90.obj
f951.exe: Warning: Nonexistent include directory 'C:/Dev/msys64/mingw64/lib/libffi-3.2.1/include' [-Wmissing-include-dirs]
C:/Users/Francisco/Desktop/test/gtk-fortran-gtk3/build/sketcher/gtkf-sketcher.out.f90:596:132:

  596 | call execute_command_line("python3 C:/Program Files (x86)/gtk-fortran/bin/gtk-3-fortran-pymodscan .", exitstat=shellout_err)
      |
     1
Error: Line truncated at (1) [-Werror=line-truncation]
C:/Users/Francisco/Desktop/test/gtk-fortran-gtk3/build/sketcher/gtkf-sketcher.out.f90:596:132:

  596 | call execute_command_line("python3 C:/Program Files (x86)/gtk-fortran/bin/gtk-3-fortran-pymodscan .", exitstat=shellout_err)
      |
     1
Error: Syntax error in argument list at (1)
C:/Users/Francisco/Desktop/test/gtk-fortran-gtk3/build/sketcher/gtkf-sketcher.out.f90:878:7:

  878 | use handlers
      | 1
Fatal Error: Cannot open module file 'handlers.mod' for reading at (1): No such file or directory
f951.exe: some warnings being treated as errors
compilation terminated.
make[2]: *** [sketcher/CMakeFiles/gtkf-sketcher.dir/build.make:83: sketcher/CMakeFiles/gtkf-sketcher.dir/gtkf-sketcher.out.f90.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1518: sketcher/CMakeFiles/gtkf-sketcher.dir/all] Error 2
make: *** [Makefile:183: all] Error 2

```

After splitting the culprit line in /build/sketcher/gtkf-sketcher.out.f90 and doing `make` again it works fine.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 24, 2020, 9:03pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/25 "2020-07-24T21:03:30Z")

</div>

Thanks very much! That code was added this week. And the path to `gtk-3-fortran-pymodscan` is added by CMake. It is probably a little bit longer in Windows if you install in C:\Program Files (x86). I will work on that tomorrow.

Note also that I have recently added on the wiki:

> - Install the gtk-?-fortran library into your MSYS2 directory (by default CMake uses C:\Program Files (x86) but the spaces will cause problems with pkg-config):
> 
> `$ MSYS2_ARG_CONV_EXCL=- cmake . -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX $ make -j install DESTDIR=/`
> 
> That solution was found at [cmake msys2, wrong install path for library - Stack Overflow](https://stackoverflow.com/questions/44282788/cmake-msys2-wrong-install-path-for-library)

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://fortran-lang.discourse.group/u/stavros)\
**Post date:** [July 25, 2020, 8:09am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/26 "2020-07-25T08:09:46Z")

</div>

Hi @vmagnin, I just started with gtk-3-fortran. I followed the installation instructions, and everything was installed successfully and a couple of examples that I tested also run ok.  
Just completed your first tutorial as well. Thank you for all the work you are doing there!

I only want to note a small detail and please correct me if I am wrong: gtk-3-fortran lib seems to be compiled with GNU Fortran v7.5.0? When tried your first tutorial I had to go backwards from 10 to 9, 8, and finally got it working with 7, by replacing in the command line `gfortran` with `gfortran-7` (at least for my case that I have several versions installed).  
example error:

```bash
~/Projects/GTK_Apps/tutorials/tutorial_1$ gfortran my_first_gtk_app.f90 $(pkg-config --cflags --libs gtk-3-fortran)
my_first_gtk_app.f90:3:9:

    3 | use gtk, only: gtk_application_new, G_APPLICATION_FLAGS_NONE, &
      | 1
Fatal Error: Cannot read module file ‘/usr/local/include/gtk-3-fortran/gtk.mod’ opened at (1), because it was created by a different version of GNU Fortran
compilation terminated.

```

Nothing important, but if that is the case perhaps you could mention this at the beginning of the tutorials for new users like myself.

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 25, 2020, 8:45am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/27 "2020-07-25T08:45:57Z")

</div>

Thanks @stavros for feedback!  
Normally, it is CMake which detects the Fortran compiler of the system:

```
$ cmake ..
-- The Fortran compiler identification is GNU 9.2.1
-- Check for working Fortran compiler: /usr/bin/f95
...

```

On my Ubuntu system, I have gfortran 4.8, 5.5, 7.5, 8.5, 9.2. But the command `gfortran` corresponds to:

```
$ gfortran --version
GNU Fortran (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008

```

What are the versions printed by those two commands on your system? (and what is your system? It is an interesting problem that I have never encountered).

Note that you can choose which compiler who want to use with that command:

`$ cmake -D CMAKE_Fortran_COMPILER:FILEPATH=`which gfortran-9` ..`

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://fortran-lang.discourse.group/u/stavros)\
**Post date:** [July 25, 2020, 9:18am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/28 "2020-07-25T09:18:36Z")

</div>

You are correct and I would expect the same thing… I have installed in my system all versions from 7.5 up to 10.1 with default the latest. I am using Mint 19.1, which is based on Ubuntu 18.04.

```bash
$ gfortran --version
GNU Fortran (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0

```

I control the different versions through `update-alternatives`:

```bash
$ update-alternatives --config gfortran 
There are 4 choices for the alternative gfortran (providing /usr/bin/gfortran).

  Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gfortran-10 40 auto mode
  1 /usr/bin/gfortran-10 40 manual mode
  2 /usr/bin/gfortran-7 10 manual mode
  3 /usr/bin/gfortran-8 20 manual mode
  4 /usr/bin/gfortran-9 30 manual mode

```

however the cmake recognises 7.5 when I run it from within the project:

```bash
gtk-fortran/build$ cmake ..
-- Building gtk-3-fortran
-- GNUInstallDirs: /usr/local lib include bin share share/man
-- System: Linux 4.15.0-96-generic x86_64
-- Compiler: GNU 7.5.0 /usr/bin/f95
-- Build type is: release
-- Compilation flags: -pthread -O3 -mtune=native -march=native
-- Configuring done
-- Generating done
-- Build files have been written to:...

```

Any idea why?

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 25, 2020, 9:31am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/29 "2020-07-25T09:31:13Z")

</div>

> [@stavros](#):
>
> Any idea why?

No, I never had that problem. But I do not use `update-alternatives` (thanks, I didn’t know that command).

It seems CMake have chosen the version with the lowest priority!

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 25, 2020, 10:28am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/30 "2020-07-25T10:28:28Z")

</div>

In my notes, I had noted that CMake uses `f95`, which is a link toward the default Fortran compiler:

```
$ f95 --version
GNU Fortran (Ubuntu 9.3.0-10ubuntu2) 9.3.0
```

---

<div class="post-metadata">

**Author:** ![stavros](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@stavros](https://fortran-lang.discourse.group/u/stavros)\
**Post date:** [July 25, 2020, 6:27pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/31 "2020-07-25T18:27:57Z")

</div>

Didn’t know about f95 but I just checked and there is no difference:

```bash
$ f95 --version
GNU Fortran (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0

```

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [July 25, 2020, 7:13pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45/32 "2020-07-25T19:13:47Z")

</div>

> [@stavros](#):
>
> `update-alternatives`

Strange…  
Perhaps you could see on [https://discourse.cmake.org/](https://discourse.cmake.org/)

[Previous page](https://fortran-lang.discourse.group/t/gtk-fortran-20-04-released-preparing-for-gtk-4/45.md?page=1)
