building an MSVC app with libpurple
David Byron
dbyron at dbyron.com
Thu May 24 18:39:20 EDT 2007
I'm trying to use libpurple (built from pidgin-2.0.0.tar.bz2) in an app
that's built with the native MSVC tools. Apologies if this is more of a
glib question or a mingw question but since it's definitely a
pidgin/libpurple question I figured I'd start here.
http://www.mingw.org/mingwfaq.shtml#faq-msvcdll
makes it look fairly straightforward. As long as I have a mingw .dll file
and a .def file, I can create a .lib and go from there.
I followed the normal mingw instructions to build pidgin, configuring like
this:
../configure --enable-static --disable-shared --disable-gtkui
--enable-consoleui --disable-perl --disable-tcl --disable-tk --enable-debug
--enable-fatal-asserts
--with-static-prpls=gg,irc,jabber,msn,novell,oscar,qq,simple,yahoo,zephyr
--disable-mcheck
I only saw libpurple.dll and libpurple.dll.a, but no .def file. Given the
--disable-shared argument to configure I'm not sure why I got a .dll at all
but that's a bit of a different question.
Since I (think I) need a .def file, I modified libpurple/Makefile.mingw to
add this argument to the gcc invocation to build libpurple.dll and
libpurple.dll.a:
$(CC) -shared $(OBJECTS) $(LIB_PATHS) $(LIBS) $(DLL_LD_FLAGS)
-Wl,--output-def,$(TARGET).def,--out-implib,$(TARGET).dll.a -o $(TARGET).dll
Note the extra --output-def,$(TARGET).def.
Anyway, after rebuilding, I followed the mingw instructions and ran:
lib /machine:i386 /def:libpurple.def
and voila, a libpurple.lib.
I created a Visual Studio solution using nullclient.c and after adding the
appropriate include paths and modifying like this:
$ diff -u /cygdrive/c/archive/pidgin/pidgin-2.0.0/libpurple prpl.h
--- /cygdrive/c/archive/pidgin/pidgin-2.0.0/libpurple/prpl.h 2007-04-29
20:14:26.000000000 -0700
+++ prpl.h 2007-05-23 09:11:21.040250000 -0700
@@ -54,7 +54,9 @@
*/
#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0}
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include "blist.h"
#include "conversation.h"
everything compiled fine. I added libpurple.lib to the link line and got a
few unresolved externs:
1>nullclient.obj : error LNK2001: unresolved external symbol
_g_source_remove
1>nullclient.obj : error LNK2001: unresolved external symbol _g_timeout_add
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_io_channel_unref referenced in function _glib_input_add
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_io_add_watch_full referenced in function _glib_input_add
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_io_channel_unix_new referenced in function _glib_input_add
1>nullclient.obj : error LNK2019: unresolved external symbol _g_malloc0
referenced in function _glib_input_add
1>nullclient.obj : error LNK2019: unresolved external symbol _g_free
referenced in function _purple_glib_io_destroy
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_io_channel_unix_get_fd referenced in function _purple_glib_io_invoke
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_main_loop_run referenced in function _main
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_list_nth_data referenced in function _main
1>nullclient.obj : error LNK2019: unresolved external symbol _g_list_append
referenced in function _main
1>nullclient.obj : error LNK2019: unresolved external symbol
_g_main_loop_new referenced in function _main
These come from glib so I added glib-2.0.lib to the link line and now
everything links. Success? Unfortunately not. When I run the program, I
get an error message that says:
"This application has failed to start because libglib-2.0-0.dll was not
found. Re-installing the application may fix this problem."
I would happily add something to my path to get by this, but
gtk-dev-2.6.10-rev-a.tar.gz only has libglib-2.0.dll.a, not
libglib-2.0-0.dll.
This makes me think I need to build glib from source or to find the file I'm
looking for in another distribution (e.g.
http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.12/glib-2.12.11.zip).
That zip file does have libglib-2.0-0.dll and it makes the error go away.
The warnings on http://www.gimp.org/~tml/gimp/win32/downloads.html make me
think I'll need to build this myself before it's all over. Anyone else have
experience with this?
After this error message, I get another one libxml2 that I solve by adding
win32-dev\libxml2\bin to my path. Unfortunately, there's still another
missing dll: zlib1.dll. Again the gtk tarball has zlib.lib but no
zlib1.dll. Googling for it finds it for me, but yet another missing dll.
This time it's glib-2.0.dll....Has anyone gone down this road? It doesn't
feel like a good one. If I really need to build everything from source with
the native tools I will but I'm hoping someone knows a shorter way.
In the past I've used a wrapper like http://cccl.sourceforge.net/ so I can
still use the same autotools-based make system with the native tools but
it's usually a bit of struggle.
Thanks for all of your help.
-DB
More information about the Devel
mailing list