Installing GTK

sudo apt-get install libgtk-3-dev

Using In Your Project

Update your makefile to use the gtk libs and cflags:

LIBS = `pkg-config --libs gtk+-3.0`

CFLAGS = `pkg-config --cflags gtk+-3.0`

Include gtk and get programming – see here.

#include <gtk/gtk.h>

Using In A NetBeans For Windows Project

Go to: Project Properties > Build > Linker > Compilation Line > Additional Options > paste in this:
         `pkg-config –cflags gtk+-3.0` `pkg-config –libs gtk+-3.0`

Note the single quote marks are correct and should be used as is!

Now you need to add all of the directories used by the gtk libraries – dull but necessary…  Use this command:

pkg-config --cflags gtk+-3.0

Which will give you an output like this:

pkg-config --cflags gtk+-3.0
-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/arm-linux-gnueabihf/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include

Convert it into a list of directories and delete any duplicates, so you end up with something like this:


Go to: Project Properties > Build > C++ Compiler > General > Include Directories > and add in each one.  For the first one you can paste the line in even though an open file dialog is shown but you may need to go back and edit it to make it right.  For subsequent ones you can simply 'duplicate' and then 'edit' to add each as a new entry.

This it, add this to your project source file and off you go.

#include <gtk/gtk.h>



We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.