To use GTK+ with your own applications, you must first get a proper development system installed. Detailed instructions exist at www.gimp.org/win32, but I'll outline the basics here.
First, install a basic development environment, such as Dev-C++, mingw, or MSVC++. For the purpose of this guide, I'll use Dev-C++ 5, installed at C:\Code\Dev-C++, as an example.
Next, download the GTK+ Development Environment from the download page. Double-click it to begin the installation, and after agreeing to abide by the terms of the GPL, you will be asked where to install the GTK+ libraries. You'll want to install them to the base directory of your development environment; using the example above, this would be C:\Code\Dev-C++. The installer should warn you that the directory already exists; confirm that this is OK and continue.
Now you need to to ensure your program can find the GTK+ libraries at build time. This varies depending on your environment, but you'll basically need to link the following libraries with your project:
-lgtk-win32-2.0 -lgdk-win32-2.0 -lgthread-2.0 -lgdi32 -lole32 -luuid -latk-1.0
-lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0
-lgmodule-2.0 -lglib-2.0 -lintl -liconv
In our Dev-C++ example, this would be done by clicking "Project->Project Options", selecting the "Parameters" tab, and
You will also need these header directories:
[INCLUDE]\gtk-2.0
[INCLUDE]\gtkdeps-2.0
[INCLUDE]\atk-1.0
[INCLUDE]\pango-1.0
[INCLUDE]\glib-2.0
[LIB]\glib-2.0
[LIB]\glib-2.0\include
[LIB]\gtk-2.0\include
[INCLUDE] is the full path to the include directory, and [LIB] is the full path to the library directory. In our example, these would be C:\Code\Dev-C++\include and C:\Code\Dev-C++\lib, respectively. To add these directories in Dev-C++, click "Project->Project Options", select the "Directories" tab, and select the "Include Directories" tab inside of that. Type the full address of each header directory, one at a time, into the entry box, clicking "Add" after each one.
If you're using gcc-2.95.x to compile, you'll need to pass the -mno-cygwin and -fnative-struct options to the compiler. With gcc-3.x, pass -mno-cygwin and -mms-bitfields. Following our Dev-C++ example, you would click "Project->Project Options", select "Parameters", and add the appropriate options into the "Compiler" entry.
The final step is to ensure the GTK+ Runtime Environment is installed and available to your applications. To do this, you'll need to edit your PATH environment variable. On Windows 2000 and Windows XP, this can be done by right-click on "My Computer", selecting "Properties", and clicking the "Advanced" tab. Click the "Environment Variables" button, and double-click the "PATH" item in the "System variables" frame. At the end of the "Variable value" entry, append the path you installed the GTK+ Runtime Environment to. For example, if you installed to "C:\GTK+ Runtime", and your existing PATH was "%SystemRoot%\system32", edit your path to read "%SystemRoot%\system32;C:\GTK+ Runtime\bin;C:\GTK+ Runtime\lib". Then click "OK" to save this new value.
Now you should be all set to begin developing your own GTK+ applications!
Tips for MSCV Users
Contributed by Bill Nalen
Download and install the developer package as above. I will use c:\gtk2dev\ as the install point, substitute your directory as needed.
Compile Options:
I prefer to use the additional include path in the preprocessor section of the C/C++ tab. The Additional Include Directories box should include the following:
C:\GTK2DEV\INCLUDE\GTK-2.0,C:\GTK2DEV\LIB\GTK-2.0\INCLUDE,C:
\GTK2DEV\INCLUDE\GLIB-2.0,C:\GTK2DEV\LIB\GLIB-2.0\INCLUDE,C:
\GTK2DEV\INCLUDE\PANGO-1.0,C:\GTK2DEV\INCLUDE\ATK-1.0,c:\gtk2dev\include
The Code Generation item should use the multi-threaded dll (debug or normal) in the run-time library drop down.
Link Options:
On the Link tab on the Input drop down page, we need to fill in the Object/Library modules and add the path to the Additional Library Path. Add the following to the Object/Library Modules line:
glib-2.0.lib gtk-win32-2.0.lib gdk-win32-2.0.lib gobject-2.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib gmodule-2.0.lib pango-1.0.lib
You may also need intl.lib on this line.
The Additional Library Path statement just needs:
C:\GTK2DEV\LIB
I may have missed some libraries that you may need to compile but you should be able to add those easily. You could also add the paths above to the libraries and include items under Tools - Options - Directories.
|