Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "SWT/Devel/Gtk/pkg-config compiled GTK"
(→Compiling with after pkg-config modifications) |
|||
Line 45: | Line 45: | ||
== Compiling with after pkg-config modifications == | == Compiling with after pkg-config modifications == | ||
− | After you've modified the necessary .pc files, | + | After you've modified the necessary .pc files, compile your application as usual using pkg-config. The compilation will now use the .SO files from the compiled GTK version, not the ones on your system. |
Latest revision as of 14:00, 22 August 2018
Contents
Getting started
Sometimes it's necessary to write native GTK snippets to reproduce issues that could be bugs in GTK itself. Of course, it's also important to be able to test these snippets across multiple versions of GTK, specifically GTK3. As a prerequisite, please see the article about compiling GTK. After you've compiled your version of GTK and have a .libs directory, proceed to the next step.
Compiling GTK applications using system GTK
GTK compiles its applications using information from pkg-config. pkg-config has rule files that it uses to store information about the program's needs. These files are located in:
/usr/lib64/pkgconfig
Compiling an ordinary GTK application using your system GTK is easy. Follow the steps here and you are done: https://developer.gnome.org/gtk3/stable/gtk-compiling.html But compiling a GTK application using your "custom" compiled GTK libraries requires modification of the pkg-config rule files.
Modifying pkg-config rule files
Navigate to the following directory:
/usr/lib64/pkgconfig
Using sudo/elevated permissions, make a copy of the gdk-3.0.pc and gtk+-3.0.pc files. You'll want to have a backup in case something goes wrong. Note: if you want use modified libraries for other GTK dependencies (like Cairo, Pixman, etc.), you can find those rules files as well.
Next, we are going to edit them. The default gtk+-3.0.pc file should look like this:
prefix=/usr exec_prefix=/usr libdir=/home/ericwill/src/gtk_versions/current/gtk/gtk includedir=/home/ericwill/src/gtk_versions/current/gtk targets=x11 broadway wayland gtk_binary_version=3.0.0 gtk_host=x86_64-redhat-linux-gnu Name: GTK+ Description: GTK+ Graphical UI Library Version: 3.18.2 Requires: gdk-3.0 atk >= 2.15.1 cairo >= 1.14.0 cairo-gobject >= 1.14.0 gdk-pixbuf-2.0 >= 2.30.0 gio-2.0 >= 2.45.8 Requires.private: atk atk-bridge-2.0 wayland-client >= 1.5.91 xkbcommon >= 0.2.0 wayland-cursor >= 1.5.91 wayland-egl epoxy >= 1.0 pangoft2 gio-unix-2.0 >= 2.45.8 Libs: -L${libdir} -lgtk-3 Cflags: -I${includedir}
We will need to edit two lines: libdir, and includedir. Libdir should be set to the directory that the compiled .libs folder sits in. The includedir value should reflect the root of your compiled GTK. For example:
includedir=<location to compiled folder>/gtk/gtk libdir=<location to compiled folder>/gtk
The libdir value needs to be changed for gdk-3.0.pc, but the includedir can remain the same:
includedir=<location to compiled folder>/gtk/gdk libdir=<location to compiled folder>/gtk
Compiling with after pkg-config modifications
After you've modified the necessary .pc files, compile your application as usual using pkg-config. The compilation will now use the .SO files from the compiled GTK version, not the ones on your system.