We demonstrate how the Fortran Package Manager fpm can be used to build and run a gtk-fortran program, using gtk-fortran as a fpm dependency. The present gtkzero_fpm example is based on the GTK 4 gtkzero_gapp example and just opens an empty GTK window.
- The GTK 4 development files are supposed to be installed on your system.
 - You need fpm,
 - and a modern Fortran compiler (>= Fortran 2008).
 
The original gtkzero_gapp.f90 has been divided in two files main.f90 and handlers.f90. This is the tree of the project, before building:
├── app
│   └── main.f90
├── build
├── fpm.toml
├── LICENSE
├── README.md
├── src
│   └── handlers.f90
└── test
    └── check.f90The fpm.toml manifest must contain a dependencies section with gtk-fortran:
[dependencies]
gtk-fortran = { git = "https://github.com/vmagnin/gtk-fortran.git", branch = "gtk4" }The project can be downloaded, built and run very simply:
$ git clone [email protected]:vmagnin/gtkzero_fpm.git
$ cd gtkzero_fpm
$ fpm runYou should see on screen an empty GTK window with an "hello world" title.
This example is under MIT license. You can therefore use it to begin your own project, and just copy that license above the concerned code sections.