-
Notifications
You must be signed in to change notification settings - Fork 46
Tutorial 5
We demonstrate how the Fortran Package Manager fpm can be used to build and run a gtk-fortran program, starting from the gtkzero_gapp.f90 example, which just opens an empty GTK 4 window. The source of the resulting fpm project is available in the following repository:
https://github.com/vmagnin/gtkzero_fpm
- gtk-fortran >= 4.2.
- The Fortran Package Manager fpm.
- GTK 4 and its development files.
- The git version control system.
An hello world project is first created by:
$ fpm new gtkzero_fpm
$ cd gtkzero_fpm
The gtkzero_gapp.f90
file is just composed of the main Fortran program and a module named handlers
. In the fpm version, we put the main program into the app/main.f90
file and the module into src/handlers.f90
(the file must have the name of the module).
The tree of the project is:
├── app
│ └── main.f90
├── build
├── fpm.toml
├── README.md
├── src
│ └── handlers.f90
└── test
└── check.f90
The fpm.toml
manifest must contain a dependencies section with the needed branch of gtk-fortran:
[dependencies]
gtk-fortran = { git = "https://github.com/vmagnin/gtk-fortran.git", branch = "gtk4" }
The project can then be built and run very simply:
$ fpm run
After having cloned gtk-fortran in the build/dependencies/
directory of the project, fpm will build everything and run the executable. You should see on screen an empty GTK window with an "hello world" title.
That's all folks!
If you have several projects using gtk-fortran, it would be a better solution to clone the gtk-fortran repository alongside your projects and replace in their fpm.toml
manifest the git dependency by the local path to gtk-fortran:
[dependencies]
gtk-fortran = { path = "../gtk-fortran" }
- Installation
- My first gtk-fortran application
- Drawing an image in a PNG file (without GUI)
- A program also usable without GUI
- Using Glade3 and gtkf-sketcher (GTK 3)
- Using gtk-fortran as a fpm dependency
- Debugging with GtkInspector
- Learning from examples
- Video tutorials
- How to start my own project from a gtk-fortran example
- git basics
- CMake basics
- Alternatives to CMake
- How to migrate to GTK 4
- How to contribute to gtk-fortran
- How to hack the cfwrapper with other C libraries