Compiling libpurple in Visual Studio

Nick Hebner hebnern at gmail.com
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:
------------------------------------------------
$PIDGIN_DEV_ROOT\win32-dev\gtk_2_0\include\glib-2.0
$PIDGIN_DEV_ROOT\win32-dev\gtk_2_0\lib\glib-2.0\include
$PIDGIN_DEV_ROOT\win32-dev\gtk_2_0\include
$PIDGIN_DEV_ROOT\win32-dev\libxml2\include

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

Linker::General::Additional Library Directories:
------------------------------------------------
$PIDGIN_DEV_ROOT\win32-dev\gtk_2_0\lib
$PIDGIN_DEV_ROOT\win32-dev\libxml2\lib

Linker::Input::Additional Dependencies:
------------------------------------------------
glib-2.0.lib
gmodule-2.0.lib
gobject-2.0.lib
gthread-2.0.lib
libxml2.lib
intl.lib
iconv.lib
ws2_32.lib

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: <http://pidgin.im/pipermail/devel/attachments/20070528/d782b87d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpurple.patch
Type: application/octet-stream
Size: 9127 bytes
Desc: not available
URL: <http://pidgin.im/pipermail/devel/attachments/20070528/d782b87d/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpurple.win32.patch
Type: application/octet-stream
Size: 2303 bytes
Desc: not available
URL: <http://pidgin.im/pipermail/devel/attachments/20070528/d782b87d/attachment-0005.obj>


More information about the Devel mailing list