Skip to content

Devel GTK Compiling Gtk

Simeon Andreev edited this page Feb 23, 2023 · 1 revision

Getting GTK

Make sure you have git installed, and then clone the GTK git repository using the following command in the directory you wish to have the GTK repository:

git clone https://github.com/GNOME/gtk.git

This will create a gtk directory in your current directory. Enter this directory once git has finished downloading all the files.

GTK Versions

You can see which versions are available to checkout by typing:

git branch -a

Checkout the tag with the version of GTK that you want. For example, if I wanted to checkout GTK3.12.2, it would usually look like this:

git checkout 3.12.2

Note that after you switch branches, you need to do a git clean to remove any changes between branches. Run this command:

git clean -xdf            #d=directory, f=force, x=clean ignored files

Compiling GTK

When in the parent gtk directory, run the following commands in order, after each one stops executing:

./autogen.sh
./configure
make

This process outputs .SO files which can be fed to SWT applications using LD_LIBRARY_PATH. The script below compiles GTK and gathers the .SO files in a ~/gtk_src folder.

cd /home/ericwill/git/gtk/
git clean -xdf
./autogen.sh
./configure
make
find . -name "*.so*" -exec cp {} ~/gtk_src/ \;

Dealing with make build failures

Building GTK can be a tricky. You may run into the following issues:

Build failure due to missing packages

The build can fail if you are missing certain packages.

For example make may fail with:

gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory

In such cases you can do the following to resolve the build issues:

  • Google the error message/file. Ex google "redhat-hardened-cc1: No such file or directory. You often bump into threads that tell you which packages to install.
  • Use dnf to find out which package contains the necessary file:
sudo dnf provides '*/redhat-hardened-cc1'

Incorrect versions of libraries

You may run into error messages during configuration about some of your libraries being too old. To resolve this issue, the easiest way is to upgrade your Fedora (or other linux distro) to the newest or beta versions (rawhide).

Use compiled GTK libraries with SWT snippets

To find out how to run SWT snippets with the compiled GTK, see this section in the SWT GTK development guide.

Clone this wiki locally