Using GTK + in Visual C ++

I want to use GTK for the user interface for a C ++ project. I do not know how to set up a development environment for it. I downloaded the all-in-one gtk kit from http://www.gtk.org/download-windows.html How to use it with Visual C ++ 2008?

+6
c ++ visual-c ++ gtk
source share
4 answers

There are some old teams here and here . You may have to customize them for your needs.

GTK also has several 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 is also the irc channel, # gtk + on irc.gnome.org. My experience is that you get either quick answers or answers in general.

If you can, you can try switching from Visual C ++ to mingw, which is a Unix / Linux system, similar to a build for Windows. Very few GTK developers use it on Windows, and almost all of these people use mingw.

+3
source share

I got a Hello World tutorial here: http://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD for working with Visual C ++ 10 in 32-bit version of Windows 7. Here are the steps that I went through (assuming you installed GTK + in C:\GTK+ ):

Go to Properties / Configuration Properties / Debugging and add it to the environment

 PATH=%PATH%;C:\GTK+\bin 

Go to Properties / Configuration Properties / C / C ++ / General and add Include to Additional Directories (I'm sure there is 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 additional library dependencies:

 C:\GTK+\lib 

Finally Properties / Configuration / 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 feel that if you use more commands there might be some libraries / headers that I forgot. This should provide a good foundation, although for any programming with GTK + in Visual C ++

+6
source share

For any type of library, you first need to make sure you have available lib files and associated headers. After that, you simply change the properties of your projects in the C ++> General> Additional Include directories to contain the path to the headers, and also in 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) to the .lib files you need.

+3
source share

I was going to post it as a comment on @Anthony's answer, but it gave me โ€œtoo many charactersโ€, and as an answer I can use formatting and make it more readable.

I followed Anthony's explanation, and everything worked out perfectly. I collected only a hello world, though. I'm on a Windows 8 64-bit machine, but my VS-target is x86, so I downloaded gtk + 32-bit.

If you are using Visual Studio 13 and GTK + 3.6.4 , provided that you have installed GTK in the C:\gtk directory, here Properties/C/C++/General/Additional Include Directories :

C: \ GTK \ enable \ GTK-3.0; C: \ GTK \ include \ reddish-2.0; C: \ GTK \ include \ Cairo; C: \ GTK \ include \ Pango-1.0; C: \ GTK \ include \ GTK-3.0 \ GOK; C: \ GTK \ include \ GDK-pixbuf-2.0; C: \ GTK \ include \ aka-1,0; C: \ GTK \ Lib \ brisk-2.0 \ includes

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; lively-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)

0
source share

All Articles