I want to use GTK for user interface for C++ project. I do not know how to set development environment for it. I downloaded all-in-one bundle of gtk from http://www.gtk.org/download-windows.html How to use it with visual c++ 2008 ?
6 Answers
I have gotten the Hello World Tutorial explained here: http://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD to work with Visual C++ 10 in Windows 7 32-bit.
Here are the steps I went through (assuming you installed GTK+ to C:\GTK+
):
Go to Properties/Configuration Properties/Debugging and add this to the Environment
PATH=%PATH%;C:\GTK+\bin
Go to Properties/Configuration Properties/C/C++/General and add to Additional Include Directories(I'm sure there's a better way to do this but it works):
C:\GTK+\include\gtk-2.0;C:\GTK+\include\glib-2.0;C:\GTK+\lib\glib-2.0\include;C:\GTK+\include\cairo;C:\GTK+\include\pango-1.0;C:\GTK+\include\gtk-2.0\gdk;C:\GTK+\lib\gtk-2.0\include;C:\GTK+\include\gdk-pixbuf-2.0;C:\GTK+\include\atk-1.0
Properties/Configuration Properties/Linker/General and add to Additional Library Dependencies:
C:\GTK+\lib
Finally Properties/Configuration Properties/Linker/Input:
gtk-win32-2.0.lib;gdk-win32-2.0.lib;atk-1.0.lib;gdk_pixbuf-2.0.lib;pangowin32-1.0.lib;pangocairo-1.0.lib;pango-1.0.lib;cairo.lib;gthread-2.0.lib;gobject-2.0.lib;gmodule-2.0.lib;glib-2.0.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
This worked for the Hello World tutorial, but I have a feeling if you use more commands, there may be some libs/headers I left out. This should provide a good foundation though for anyone programming with GTK+ in Visual C++
-
1+1 This answer was very helpful. Although I think you forgot to mention including 'C:\GTK+\include\' itself? And also, getting the needed dll files and placing them with the executable. – AturSams Apr 17 '13 at 17:18
-
Which dlls should I put together with executable? all from C:\gtk\bin ? – Jack Jun 14 '14 at 05:02
For any kind of library, first you need to make sure you have the available lib files and associated headers. After you have those, you simply modify your projects properties under the C++ > General > Additional Include directories, to contain the path to the headers, and under the Linker > General > Additional Library Dependencies, to contain the path to your lib files. Then under Linker > Input > Additional Dependencies, you add the file name (not the full path) of the .lib files you need.

- 123
- 1
- 7
There are some old instructions here and here. You will probably have to adjust them for your needs.
GTK also has some email lists you could join to discuss this. The best lists for this particular question are gtk-app-devel-list@gnome.org or gtk-list@gnome.org.
There's also an irc channel, #gtk+ on irc.gnome.org. My experience there is you get either quick answers or no answers at all.
If you can, you might try switching from Visual C++ to mingw, which is a Unix/Linux like build system for Windows. Very few GTK developers use it on Windows, and almost all of those people use mingw.

- 5,814
- 2
- 32
- 35
I was going to post it as comment to @Anthony's answer but it gave me "too many characters" and as answer I can use formatting and make it more readable.
I followed Anthony's explanation and it worked fine. I've compiled only the hello world although. I'm on Windows 8 64-bit machine but my VS target x86 so I downloaded the gtk+ 32-bit.
If you're using Visual Studio 13 and GTK+ 3.6.4, assuming you installed GTK on C:\gtk
directory, here's the Properties/C/C++/General/Additional Include Directories
:
C:\gtk\include\gtk-3.0;C:\gtk\include\glib-2.0;C:\gtk\include\cairo;C:\gtk\include\pango-1.0;C:\gtk\include\gtk-3.0\gdk;C:\gtk\include\gdk-pixbuf-2.0;C:\gtk\include\atk-1.0;C:\gtk\lib\glib-2.0\include
And Properties/Linker/Input:
gtk-win32-3.0.lib;gdk-win32-3.0.lib;atk-1.0.lib;gdk_pixbuf-2.0.lib;pangowin32-1.0.lib;pangocairo-1.0.lib;pango-1.0.lib;cairo.lib;gthread-2.0.lib;gobject-2.0.lib;gmodule-2.0.lib;glib-2.0.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)

- 17,007
- 37
- 111
- 185
Most include paths are:
C:\gtk\include
Initially I missed out this
C:\gtk\lib\glib-2.0\include
Having added this I am able to get it running. Windows 10 X64, GTK-3.0 X64 Windows bundle, Visual Studio 2017, Visual C++ in C mode (.c files).

- 789
- 9
- 11
For Windows: Install gtk using vcpkg dependency manager (https://vcpkg.io/en/index.html); after installing vcpkg run the command
.\vcpkg install gtk
or
.\vcpkg install gtk:x64-windows
or
.\vcpkg install gtk:x86-windows

- 27,810
- 13
- 101
- 139

- 31
- 3