I have gcc installed in c:/programfiles (also set as a path variable), and i have all the necessary files for gtk from http://www.gtk.org/download-windows.html, glib,gtk,pango,atk and cairo. Although I have no clue as to how to compile a c program using gtk with the gcc compiler. How do I set everything up so that it works?. (I don't know where each zip file goes.?) basically I don't really know where start.
Ok, to install and use GTK+ in Windows and use it with MinGW you may follow these steps for example. I'll try to made them the easy, don't worry:
- Install MinGW, as you've already done it so I wont elaborate this step.
- Download the GTK+ all-in-one bundle (there may be things you may not use... but this way should work).
- Decompress the contents of the bundle, you may do it in the same folder MinGW is installed or do it in another folder, it doesn't matter.
Launch a command prompt, get to the
bin
directory where you extracted the bundle and run:pkg-config --cflags --libs gtk+-win32-2.0
It will print a list of compilation flags, and libraries to link your project to. Now, copy them and create a batch file (.bat or Windows Command Script .cmd) with the following:
set VAR=FLAGS
start cmdWhere
VAR
is a name of a variable (for example GTK) andFLAGS
is the output of the previous command (pkg-config
).Whenever you want to compile something that uses GTK+ double click that file, the GTK+ flags will be in
VAR
. You may compile this way for example:gcc foo.c %VAR%
Instead of a batch file, you may find more convenient to create an user environmental variable and store the flags in there, that way you will be able to compile from within a normal command prompt. I didn't describe that because the way to do it varies depending on the version of Windows you have. Generally you may find it in advanced system properties.
Once you are more confident in GTK+ programming you may not use all of the packages, or all the flags, or reorder them in a different manner, use makefiles instead of having the compilation flags and the libraries in an environmental variable, ...
But by now, this will get you started.
Also, you'll be linking dynamically to GTK+, so either the proper libraries are in the same directory of your project or are accessible from the path when you want to run it.