Thursday, April 2, 2009

Building GMime in Visual Studio

Installing the Necessary Dependencies

First, install GNU's iconv library for Windows. You can get a nice msi installer from http://gnuwin32.sourceforge.net/packages/libiconv.htm. Unfortunately, they only offer a Win32 installer, so hopefully that's the platform you intend to target.

Next, you'll want to grab the GLib headers and libraries for Windows. The easiest way to do that is to go to http://www.gtk.org/download.html and download the All-in-One pre-built bundle for Win32. Once downloaded, extract the zip file (the docs suggest not using WinZip due to a bug) and place them wherever you want (I put mine into C:\Users\jeff\Documents).

Configuring Visual Studio

Now that the libiconv and glib headers/libraries are installed, you'll want to configure Visual Studio to know where to find those headers and libraries.

First, go to the Tools menu and select Options...:

In the Options dialog, expand the Projects and Solutions tree item and then select VC++ Directories.

Make sure Win32 is selected in the Platform option menu and then select Executable files under Show directories for:, like so:

Scroll to the bottom of the listbox and add the bin paths for your installed libiconv and Gtk+ bundle just like in the above screenshot.

After you've added the bin paths, you'll need to add the #include paths. Select Include files under Show directories for: and, like you did for the Executable paths you added above, add the paths to the include files.

Next, you'll need to ad the library paths. Under Show directories for:, select Library files and add the appropriate paths to the bottom of the list.

And that's it! You are now ready to start building GMime!

Note: I've been using Microsoft Visual C++ 2008 Express Edition which you can download for free from Microsoft.

6 comments:

Jon said...

Why not use a cross compiler set up for compiling Windows binaries under your GNU/Linux space?

Gabor Garami said...

There are downloadable ZIP files, so you can unpack them to anwhere. usually binaries, dependencies and developer files needed for compilation.

Jeffrey Stedfast said...

Jon: I'm trying to make it easy for Windows developers to use GMime and most Windows developers use Visual Studio.

I won't likely be making packages for Windows msyelf.

Jeffrey Stedfast said...

George: yep, I linked to them in my post :-)

Unknown said...

Thanks for the guide. I managed to build GMime with Visual Studio 2008.

Could you post on how to build GMime-Sharp with Visual Studio or even Nant?

Jeffrey Stedfast said...

I haven't yet figured out how to get a build of gmime-sharp on Windows yet, but that's something I want to figure out as well. But I'm thinking I'll need the real Visual Studio first (I've been using Express).

When I figure it out, I'll be writing up a blog post about it :-)

Code Snippet Licensing

All code posted to this blog is licensed under the MIT/X11 license unless otherwise stated in the post itself.