# Gtk-fortran 4.2 released (a fpm dependency)

**URL:** <https://fortran-lang.discourse.group/t/gtk-fortran-4-2-released-a-fpm-dependency/3318>\
**Category:** Announcements\
**Created:** [April 25, 2022, 7:39am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-4-2-released-a-fpm-dependency/3318 "2022-04-25T07:39:34Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [April 25, 2022, 7:39am UTC](https://fortran-lang.discourse.group/t/gtk-fortran-4-2-released-a-fpm-dependency/3318/1 "2022-04-25T07:39:34Z")

</div>

- [gtk-fortran](https://github.com/vmagnin/gtk-fortran/wiki) 4.2.1 offers interfaces to GTK 4.6.2 and GLib 2.72.1. You can of course use it with lower GTK 4 versions, provided that you don’t call new functions. It was tested on Linux, MSYS2/Windows 10, macOS and FreeBSD.

- Thanks to @awvwgk, it can now be installed via [conda](https://github.com/conda-forge/gtk-4-fortran-feedstock) (Linux and macOS only):

```fortran
$ conda install gtk-4-fortran

```

- Last but not the least, gtk-fortran can now be used as a [fpm](https://fpm.fortran-lang.org) dependency (gtk4 branch only), as explained in the tutorial 5 [“How to use fpm to build a gtk-fortran project”](https://github.com/vmagnin/gtk-fortran/wiki/Tutorial-5), based on the [gtkzero\_fpm example](https://github.com/vmagnin/gtkzero_fpm). Supposing you have already installed fpm and the GTK 4 development files (`libgtk-4-dev` package in Ubuntu), building and running that example should be as simple as typing:

```bash
$ git clone git@github.com:vmagnin/gtkzero_fpm.git
$ cd gtkzero_fpm
$ fpm run

```

A “Hello World” GTK empty window should appear on screen:  
 ![image](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/d/deb9f0f48d1e5984399e0eb46a0584b9996d5976.png)

It’s very simple to use, the key lines in the `fpm.toml` manifest of that example being just:

```nohighlight
[dependencies]
gtk-fortran = { git = "https://github.com/vmagnin/gtk-fortran.git", branch = "gtk4" }

```

Note that 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` manifests the git dependency by the local path to gtk-fortran:

```nohighlight
[dependencies]
gtk-fortran = { path = "../gtk-fortran" }

```

Have fun! You can post issues here or on [GitHub](https://github.com/vmagnin/gtk-fortran/issues). But you can also post success 😉

---

<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:** [May 4, 2022, 1:56pm UTC](https://fortran-lang.discourse.group/t/gtk-fortran-4-2-released-a-fpm-dependency/3318/2 "2022-05-04T13:56:20Z")

</div>

Another gtk-fortran example, in the [gtk-fortran-extra](https://github.com/vmagnin/gtk-fortran-extra) repository, has become a fpm project using gtk-fortran as a dependency:

```bash
$ git clone git@github.com:vmagnin/gtk-fortran-extra.git
$ cd gtk-fortran-extra/unknown_pleasures
$ fpm run

```

 ![Screenshot from 2022-05-04 15-18-55](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/e/eb51f3f00815dbc4a857adfb1c2d67676ccebc26.jpeg)

It uses the [Cairo](https://www.cairographics.org/) vectorial drawing library, which is part of GTK.
