This document is obsoltete. The information here (complete with pictures and all) has been turned into a chapter in the Gtkmm Book available at www.gtkmm.org.
The Recommended configuration for building and running Gtkmm applications on windows is to use the freely available Visual Studio 2005 Express Edition. The following instructions descibe how to configure a workstation to build Gtkmm applications easily. If you already have Visual Studio 2005 Standard Edition or above, skip to the section titled Installing Gtkmm.
Download Visual Studio 2005 Express from here: http://msdn.microsoft.com/vstudio/express/visualc/
After installing VS 2005 Express, you'll need to download the Windows Platform SDK. Unfortunately, Microsoft requires that you validate your Windows install using the MS GenuineAdvantage ActiveX control. This basically means that you will have to download the Platform SDK using Internet Explorer from a Windows box with a valid license.
Download the Platform SDK from here.
After installing the Platform SDK, use the instructions here to configure Visual Studio to use it to build native Win32 Applications:
Once Visual Studio is installed and has been configured to build native Win32 applications, you must install the Gtk+ and Gtkmm development packages. First, download and install the Gtk+ development package (listed as gtk+-win32-devel) from the GladeWin32 website. Next, download the Gtkmm development package from the Gnome FTP site. Make sure you get the same version of both packages. At the time of this writing, the latest version is 2.10. Do not be afraid of the size of the development packages as they are much larger than the runtime packages which your end users will depend on.
Now that Gtk+ and gtkmm are installed, you will need to create a new project in Visual Studio. This is fairly straight forward, but there are a few things worth noting which will make it easier.
First, create a new project in Visual Stuido by Selecting New Project in the File menu as shown in Figure 1. From the New Project window, make sure to select Win32 and Console Application as shown in Figure 2. Also, give your project a name and a location. For this example, the name of the project is gtkmm_test and the location is C:\work.
Figure 1: Selecting New Project from the menu.
Figure 2: Selecting Win32 Console Application.
Figure 3: Verifying Application Settings.
This will create for you a new native Win32 console project. Now we need to modify this project to use Gtkmm.
Figure 4: Fresh New Project
Figure 5: Corrected main() function.
The next thing to alter is the stdafx.h precompiled header file. As of the time of this writing, precompiled header files are a concept that most Windows programmers are familiar with, but most Unix programmers don't know very much about, as precompiled header support was only recently added to GCC (in version 3.4). Unix programmers may be tempted to just disable precompiled headers altogether, but think carefully before you do this. Proper use of precompiled headers provides a much improved compile time, and will save you much time over the course of a project.
Figure 6 shows how to change the default stdafx.h to be more portable, also adding the include line for the gtkmm.h header file. These changes include removing the #pragma once line and replacing it with a standard #ifdef include guard as well as removing the tchar.h include. It is advisable to put all of your Gtkmm related headers (e.g.: libglademm.h, libxml++, etc.) in this file as opposed to other files as this will greatly speed up the compilation of your project.
Figure 6: Corrected stdafx.h header file.
Next, add the contents of a simple Gtkmm program to the main() function. The example shown in Figure 7 is the one from the Gtkmm Book.
Figure 7: Simple Gtkmm Program.
The next step is to add the MSVC Property files which come with the Gtkmm distribution. As of the 2005 version, Visual Studio supports the use of property files. Property files contain build settings of all kinds (e.g.: defines, include paths, link paths, libraries) and make it easy to build against 3rd party packages. When a property file is added to a project, the project inherits all the build settings which the property file specifies. To keep your project portable (portable in the relative path vs. fixed path sense), you will want to copy the property files from the Gtkmm distribution (commonly C:\Gtk\MSVC\) to the directory which contains your project (in our case C:\work\gtkmm_test\).
Figure 8: Visual Stuio Property files in the Gtkmm Distribution.
Next, add the property files to your project. Do this by clicking the Property Manager tab of your Solution explorer as indicated in Figure 10.
Figure 10: Property Manager (left) with Property Manager tab circled.
Right-Click on the Debug | Win32 folder and select Add Existing Property Sheet. From the file browser, select the file gtkmm-2.4d.vsprops. Next, Right-Click on the Release | Win32 folder and again select Add Existing Property Sheet. From the file browser, this time select the file gtkmm-2.4.vsprops. When you are done, the Property Manager should look like the one in figure 12.
Figure 11: Adding an Existing Property Sheet.
Figure 12: Property manager with Gtkmm property files added.
At this point we're almost done. The last part is to change a few settings in the Project Properties page. The easiest way to get to this page is to right-click on the project name in the Solution Explorer and click the Properties menu item as shown in Figure 13.
Figure 13: Opening the Project Properties.
The first thing to do is remove the $(NoInherit) option from the linker settings as shown in Figure 14. Get to the linker page using the tree on the left. Open Configuration Properties, then Linker, then click on Input. Now remove the $(NoInherit) token from the Additional Dependencies line. Make sure to do this in both Debug and Release modes.
Figure 14: Removing the $(NoInherit) flag.
At this point your application will build and run. However, The Gtkmm sources will generate a harmless warning during the build. Fortunately, this warning can be disbled from the same Project Settings dialog. In the tree on the left of the dialog, open Configuration Properties, then C/C++, then click Advanced. Now type 4250 in the Disable Specific Warnings field as shown in Figure 15. Make sure to make this change in both Release and Debug modes. Press Ok when done.
Figure 15: Disabling warning 4250.
If you build and run your application now, you will see a simple Gtk+ window appear with nothing on it. Your application will also pop up a console window with it. The console window is quite valuable for debugging a Gtkmm application because many Gtk+ warnings will print to this console and nowhere else (unlike the OutputDebugString() or TRACE() functions which Windows programmers are familiar with). When you release your application however, you will probably want to have it not pop up the console. This requires two small changes to the linker settings. From the tree on the left of the properties page, open Configuration Properties, then Linker, then System. Now change the value of the Subsystem field from CONSOLE to WINDOWS as shown in Figure 16. This will disable the creation of the console window when your app starts. When you do this, you also have to change the entry point of your application. From the tree on the left, select Advanced then change the Entry Point field to read mainCRTStartup (make sure to use the proper case) as shown in Figure 17. Some users have found it convenient to leave the console active in Debug mode and disabled in Release mode. Others will want to have it the same in both modes. It is completely up to the preference of the developer. Press Ok when done.
Figure 16: Setting the Subsystem to Windows to disable the console.
Figure 17: Setting the correct entry point symbol for Windows programs using main().
That's all there is to it. I hope this guide has made your transition to Gtkmm easier. If you run into any problems, I can be found on the Gtkmm Mailing List. Many thanks to Cedric Gustin for his work on the Packaging of Gtkmm for Windows.
February 4, 2007