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 about documentation.
Regrettably, it is true there is very few books about GTK. In the Tutorials page, you will find those two books:
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).
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.
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):
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:
~/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.
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:
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.
$ gfortran --version
GNU Fortran (Ubuntu 10.1.0-2ubuntu1~18.04) 10.1.0
I control the different versions through update-alternatives:
$ 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:
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:...