Compiling Gtk+ App on Windows

Posted: April 28, 2012 in C/C++, Programming
Tags: , ,

Currently i need to obtain depth map using stereo images and  Block Matching Algorithm in OpenCV painfully requires many parameter adjustments.  Then i found out Stereo BM Tuner by Martin Perris (http://blog.martinperis.com/2011/08/opencv-stereo-matching.html) is quite handy and useful. The only problem he developed this tool using Linux and Gtk+ (Ok, i am Visual Studio user XD ) so i need to port it to Windows.

Actually the porting was not that difficult, and after 2 hours of googling i found the solution:

First you need to download Gtk+ fow Windows 32bit and you should download the all-in-one bundle version (http://www.gtk.org/download/win32.php, dependencies included), zipped version, contains all dll, lib, and include files.

Open your Project through Visual Studio and right click–> Project Properties –> C/C++ section –> Additional Include Directories:

{your gtk+ bundle directory}\include;
{your gtk+ bundle directory}\include\gtk-2.0;
{your gtk+ bundle directory}\include\atk-1.0;
{your gtk+ bundle directory}\include\freetype2;
{your gtk+ bundle directory}\include\gail-1.0;
{your gtk+ bundle directory}\include\gdk-pixbuf-2.0;
{your gtk+ bundle directory}\include\gio-win32-2.0;
{your gtk+ bundle directory}\include\glib-2.0;
{your gtk+ bundle directory}\include\pango-1.0;
{your gtk+ bundle directory}\lib\glib-2.0\include;
{your gtk+ bundle directory}\include\cairo;
{your gtk+ bundle directory}\lib\gtk-2.0\include;

Project Properties –> Linker –> General –> Additional Library Directories:

{your gtk+ bundle directory}\lib

Project Properties –> Linker –> Input –> Additional Dependencies:

atk-1.0.lib
cairo.lib
expat.lib
fontconfig.lib
freetype.lib
gailutil.lib
gdk_pixbuf-2.0.lib
gdk-win32-2.0.lib
gio-2.0.lib
glib-2.0.lib
gmodule-2.0.lib
gobject-2.0.lib
gthread-2.0.lib
gtk-win32-2.0.lib
intl.lib
libpng.lib
pango-1.0.lib
pangocairo-1.0.lib
pangoft2-1.0.lib
pangowin32-1.0.lib
zdll.lib

And don’t forget Project Properties –> Linker –>System –>  SubSystem should be set as Console (/SUBSYSTEM:CONSOLE)

Then we need to modify every callback function, for example:

extern "C" __declspec(dllexport)
G_MODULE_EXPORT void on_adjustment1_value_changed( GtkAdjustment *adjustment, ChData *data )
{
    ...
}

Last step you need to copy the .glade file and all of files in {your gtk+ bundle directory}\bin (except the .exe files) on the binary folder (bin\Debug or bin\Release)

Comments
  1. Dedy says:

    hai, I’m learning create GUI using GTK+. I wanna ask if it possible to display video camera using GTK+?

    thanks

  2. Joe McGlinchy says:

    Hi!

    Thanks for this article. I have been trying to get this working on my windows machine, as I also find the tuning of the stereo matching parameters to be very useful. Unfortunately, I am running into some errors.

    First, I cannot build the project in Visual Studio 2010. I am receiving errors on every line I included “extern “C” __declspec(dllexport)” aboce the declaration of each callback function. The error is:

    Error 1 error C2059: syntax error : ‘string’ c:\users\jose6641\documents\visual studio 2010\projects\stereo_tuner\stereo_app\main.c 106 1 stereo_app

    Also, in my GTK install directory (the all in one bundle), I see no .glade file in the bin directory. Should it be there?

    Cheers,
    Joe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s