Compiling libpurple in Visual Studio

Nick Hebner hebnern at
Mon May 28 03:00:28 EDT 2007

Inspired by David Byron's recent successful tackling of libpurple use from
MSVC, I decided to give the entire compilation of libpurple in Visual Studio
a try (in order to build with debuggable symbols). After a few hours at it,
I have gotten it to compile and work (mostly... more on this later) with the
nullclient program. Surprisingly, I only had to make a few slight
modifications in code (patches attached) to deal with compiler
idiosyncracies, although I am not sure that all of these are the right thing
to do. In order to export all of the required symbols, functions have to
either be marked for export, or a .def file must be provided specifying
functions to export. I am doing the latter, using the .def file produced by
the compile under cygwin/MinGW.

The problem: I am experiencing a crash in purple_util_write_data_to_file in
util.c  when the nullclient program tries to save the buddy list. It appears
that g_fopen (ln 2431) returns a non-null FILE*, but the internal members of
this are not valid. Then when it is used in fwrite (ln 2443) it blows up.

My method:

1. Create an empty dll project
2. Add version.h, and config.h from pidgin root
3. Add all .c and .h from libpurple directory (except purple-client* files)
4. Add libpurple\win32 directory (only need .c, .h, and .rc files)
5. Apply attached patches (1 for libpurple, and 1 for win32 directory)

My Visual Studio Project Properties:

C/C++::General::Additional Include Directories:

C/C++::Advanced::Force Includes:
winsock2.h; config.h

Linker::General::Additional Library Directories:

Linker::Input::Additional Dependencies:

Linker::Input::Module Definition File:
libpurple.def (generated by the mingw compile)

Resources::General::Additional Include Directories

If anyone is interested, I can supply my project files (although there
should be enough here to reproduce them). This was done in the interest of
pursuing the development of a native UI for windows.

-Nick Hebner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpurple.patch
Type: application/octet-stream
Size: 9127 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpurple.win32.patch
Type: application/octet-stream
Size: 2303 bytes
Desc: not available
URL: <>

More information about the Devel mailing list