{"id":1541,"date":"2013-12-19T18:03:57","date_gmt":"2013-12-19T18:03:57","guid":{"rendered":"https:\/\/raspberry-projects.com\/pi\/?p=1541"},"modified":"2015-10-27T16:19:35","modified_gmt":"2015-10-27T16:19:35","slug":"installing-gtk","status":"publish","type":"post","link":"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/gui-programming-in-c\/gtk\/installing-gtk","title":{"rendered":".Installing GTK"},"content":{"rendered":"<p>\n&nbsp;\n<\/p>\n<h4>\nInstalling GTK<br \/>\n<\/h4>\n<pre>\r\n<code>\r\nsudo apt-get install libgtk-3-dev\r\n<\/code><\/pre>\n<h4>\nUsing In Your Project<br \/>\n<\/h4>\n<p>\nUpdate your makefile&nbsp;to use the gtk&nbsp;libs and cflags:\n<\/p>\n<pre>\r\n<code>\r\nLIBS = `pkg-config --libs gtk+-3.0`\r\n\r\nCFLAGS = `pkg-config --cflags gtk+-3.0`\r\n<\/code><\/pre>\n<p>\nInclude gtk&nbsp;and get programming&nbsp;&#8211; see <a href=\"https:\/\/raspberry-projects.com\/pi\/programming-in-c\/gui-programming-in-c\/gtk\/creating-a-gtk-applicaiton\">here<\/a>.\n<\/p>\n<pre>\r\n<code>\r\n#include &lt;gtk\/gtk.h&gt;\r\n<\/code><\/pre>\n<h4>\nUsing In A&nbsp;NetBeans For Windows Project<br \/>\n<\/h4>\n<p>\nGo to: Project Properties &gt; Build &gt; Linker &gt; Compilation Line &gt; Additional Options &gt; paste in this:<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`pkg-config &#8211;cflags gtk+-3.0` `pkg-config &#8211;libs gtk+-3.0`\n<\/p>\n<p>\nNote the single quote marks are correct and should be used as is!\n<\/p>\n<p>\nNow you need to add all of the directories used by the gtk libraries &#8211; dull but necessary&#8230; &nbsp;Use this command:\n<\/p>\n<pre>\r\n<code>\r\npkg-config --cflags gtk+-3.0\r\n<\/code><\/pre>\n<p>\nWhich will give you an output like this:\n<\/p>\n<pre>\r\n<code>\r\npkg-config --cflags gtk+-3.0\r\n-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\r\n<\/code><\/pre>\n<p>\nConvert it into a list of directories and delete any duplicates, so you end up with something like this:\n<\/p>\n<pre>\r\n<code>\r\n\/usr\/include\/gtk-3.0\r\n\/usr\/include\/at-spi2-atk\/2.0\r\n\/usr\/include\/at-spi-2.0\r\n\/usr\/include\/dbus-1.0\r\n\/usr\/lib\/arm-linux-gnueabihf\/dbus-1.0\/include\r\n\/usr\/include\/gio-unix-2.0\/\r\n\/usr\/include\/cairo\r\n\/usr\/include\/pango-1.0\r\n\/usr\/include\/harfbuzz\r\n\/usr\/include\/atk-1.0\r\n\/usr\/include\/pixman-1\r\n\/usr\/include\/freetype2\r\n\/usr\/include\/libpng12\r\n\/usr\/include\/gdk-pixbuf-2.0\r\n\/usr\/include\/glib-2.0\r\n\/usr\/lib\/arm-linux-gnueabihf\/glib-2.0\/include\r\n<\/code><\/pre>\n<p>\nGo to: Project Properties &gt; Build &gt; C++ Compiler&nbsp;&gt; General &gt; Include Directories &gt; and add in each one. &nbsp;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. &nbsp;For subsequent ones you can simply &#39;duplicate&#39; and then &#39;edit&#39; to add each as a new entry.\n<\/p>\n<p>\nThis it, add this to your project source file and off you go.\n<\/p>\n<pre>\r\n<code>\r\n#include &lt;gtk\/gtk.h&gt;\r\n<\/code><\/pre>\n<p>\n&nbsp;\n<\/p>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Installing GTK sudo apt-get install libgtk-3-dev Using In Your Project Update your makefile&nbsp;to use the gtk&nbsp;libs and cflags: LIBS = `pkg-config &#8211;libs gtk+-3.0` CFLAGS = `pkg-config &#8211;cflags gtk+-3.0` Include gtk&nbsp;and get programming&nbsp;&#8211; see here. #include &lt;gtk\/gtk.h&gt; Using In A&nbsp;NetBeans For Windows Project Go to: Project Properties &gt; Build &gt; Linker &gt; Compilation Line &gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[],"class_list":["post-1541","post","type-post","status-publish","format-standard","hentry","category-gtk"],"_links":{"self":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/comments?post=1541"}],"version-history":[{"count":6,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1541\/revisions"}],"predecessor-version":[{"id":2253,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/posts\/1541\/revisions\/2253"}],"wp:attachment":[{"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/media?parent=1541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/categories?post=1541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/raspberry-projects.com\/pi\/wp-json\/wp\/v2\/tags?post=1541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}