Friday, June 24, 2016

Gtk - How to Configure GTK+ Library in Eclipse

In previous post, knowledge hub has already explained how to configure gtk+ library in window and how to run it with MinGW compile via command line.

As you remember, in command line you have to type a long commands in order to compile gtk+ source code. In case of error, you have to repeatedly type command. It is a boring way to compile it in command line.
In this tutorial, knowledge hub will show you  how to configure gtk+ in Eclipse.
  • Step 1: Open Eclipse and Create new C project with any name you like. Please choose MinGW as the compiler.

  • Step 2: Right click on the project that you just created -------> New -----> Source File

  • Then, give any name you like as follows:

  • Step 3: Right click on the project that you just created -------> Choose properties

  • Then, the properties window of the project will pop up go to Settings ----->

  • Step 4: In setting, go to -----> Tool Settings -----> Includes
D:/gtk/include/gtk-3.0
D:/gtk/include/cairo
D:/gtk/include/pango-1.0
D:/gtk/include/atk-1.0
D:/gtk/include/cairo
D:/gtk/include/pixman-1
D:/gtk/include
D:/gtk/include/freetype2
D:/gtk/include/libpng15
D:/gtk/include/gdk-pixbuf-2.0
D:/gtk/include/glib-2.0
D:/gtk/lib/glib-2.0/include

Note: Please change the path above to where you install your gtk+ library on your machine


  • Step 5: In setting, go to -----> Tool Settings -----> Libraries
Libraries (-l)
gtk-3
gdk-3
gdi32
imm32
shell32
ole32
pangocairo-1.0
pangoft2-1.0
freetype
fontconfig
pangowin32-1.0
pango-1.0
m
atk-1.0
cairo-gobject
cairo
gdk_pixbuf-2.0
gio-2.0
gobject-2.0
glib-2.0
intl


Library search path (-L)
D:/gtk/lib

  • Step 6: Miscellaneous under Tool Settings
-mms-bitfields
-Wl,-luuid


  • Step 7: Then, paste the source code in the source file that you created in Step 2. Then, click compile and run. You should see as blow pic.


No comments:

Post a Comment