Up: README.md, Prev: Section 1, Next: Section 3
This section describes how to install GTK on Linux distributions.
There are two ways to install GTK:
- Install from distribution packages.
- Build from source.
This is the easiest way to install. The following command installs the GTK (version 4) development files on Ubuntu.
$ sudo apt install libgtk-4-dev
It is important to install the development package (libgtk-4-dev). Otherwise, you will not be able to compile any GTK-based programs.
Fedora, Debian, Arch, Gentoo, and OpenSUSE also have GTK packages. See the website of your distribution for further information.
Package information for Arch, Debian/Ubuntu, and Fedora is described on the GTK website: Installing GTK from packages.
If you want to install the development version of GTK, you need to build it from source. See the Compiling the GTK Libraries section of the GTK API reference.
There are two ways: zip and git.
Downloading a zip file is the easiest way.
However, if you use git and clone this repository, you can easily update your local repository with the git pull command.
- Open your browser and navigate to this repository.
- Click on the green
<> Codebutton. A dropdown menu will appear; clickDownload ZIP. - The repository will be downloaded as a zip file to your computer.
- Unzip the file.
- Click on the green
<> Codebutton. A dropdown menu will appear. The first section isClonewith three tabs. Click theHTTPStab and click the copy icon to the right ofhttps://github.com/ToshioCP/Gtk4-tutorial.git. - Open a terminal and type
git clone, then press Ctrl+Shift+V. The command line will look likegit clone https://github.com/ToshioCP/Gtk4-tutorial.git. Press Enter. - The directory
Gtk4-tutorialwill be created. This directory is a local copy of the repository.
Examples are under the src directory.
For example, the first example of the tutorial is pr1.c and its path is src/misc/pr1.c.
Therefore, you do not need to type the examples manually.