ToshioCP / Gtk4-tutorial

GTK 4 tutorial for beginners
https://toshiocp.github.io/Gtk4-tutorial/
550 stars 49 forks source link

GTK4 library installation #3

Closed dvergeylen closed 3 years ago

dvergeylen commented 3 years ago

Hi,

I'm learning how to use gtk4 and found your repo 🙂.

I think giving some hints on how to download and compile the sources for toying might be useful (at least for Debian based distros).

Here are my personal notes, taken while installing gtk4:

# Official Sources
# https://download.gnome.org/sources/gtk/4.0/ → 4.0.2 at this time of writing
cd /tmp
curl curl -L https://download.gnome.org/sources/gtk/4.0/gtk-4.0.2.tar.xz -o gtk-4.0.2.tar.xz
tar xf gtk-4.0.2.tar.xz
cd gtk-4.0.2

# Dependencies
sudo apt install meson ninja-build libxml2-utils libgraphene-1.0-dev xsltproc

# Building
meson setup -Dbuildtype=release --prefix=/tmp/gtk-lib _build .
cd _build
ninja
ninja install # Will install to the dir specified by --prefix above

# Usage
export PKG_CONFIG_PATH=/tmp/gtk-lib/lib/x86_64-linux-gnu/pkgconfig/
gcc $(pkg-config --cflags gtk4) -o example-1 example-1.c $(pkg-config --libs gtk4)

# When testing the compiled program (assuming lib isn't in library path)
export LD_LIBRARY_PATH=/tmp/gtk-lib/lib/x86_64-linux-gnu/
./example-1

Hope this helps!

Edit: Nevermind, I didn't read far enough! :see_no_evil: Section 2 details the needed instructions to install gtk4. May I then simply suggest to add -Dbuildtype=release to the meson command? Otherwise it will build a debug version of the lib. 🙂

ToshioCP commented 3 years ago

Thank you for the comment, Daniel. This information is helpful for me.

However, In my opinion, Debug builds are more appropriate than release builds at present. Gtk4 API Reference points that release builds should only be used when packaging GTK. And release builds don't give us debugging ways given by debug builds when testing your own gtk applications. They are written in Gtk4 API Reference PART VIII.

ToshioCP commented 3 years ago

The installation method is in the section 2, so this issue is now closed.