I wanted to incorporate the following guide into my tutorial on building GTK+ for Windows, but glib had trouble picking up the libintl interface library made with pexports. So I put it here separately for reference. I'll study GCC, ld, libtool, etc. further so I can make better use of pexports.
libiconv is a character-set conversion library, and GNU gettext is a tool for localizing/translating programs. For convenience, we'll just grab precompiled packages from a GNU mirror. What we need is libiconv-1.9.1.bin.woe32.zip and gettext-runtime-0.13.1.bin.woe32.zip. Unpack them into /mingw.
cd /mingw
unzip libiconv-1.9.1.bin.woe32.zip
unzip gettext-runtime-0.13.1.bin.woe32.zip
If you don't have unzip, you can build unzip by following this post. Now we just need to create import libraries from the extracted DLL's. But first use pexports to generate *.def files:
cd /mingw
pexports -h include/iconv.h bin/iconv.dll | tr -d '@[:digit:]$' > lib/libiconv.def
pexports -h include/libintl.h bin/intl.dll | tr -d '@[:digit:]$' > lib/libintl.def
pexports can be downloaded from here. Then, run dlltool
to generate import libraries like this:
cd /mingw/lib
dlltool -d libiconv.def -D iconv.dll -l libiconv.a -k
dlltool -d libintl.def -D intl.dll -l libintl.a -k
Glib Still Complaining About Gettext-Runtime?
Despite the procedure above, glib still complained about libintl when linking. The following trick will resolve the issue. Extract object codes from the interface library libintl.a
into an empty directory:
mkdir /tmp/libintl
cd /tmp/libintl
ar x /mingw/lib/libintl.a
Add the object codes into libcharset.a
cd glib/libcharset/.libs
ar r libcharset.a /tmp/libintl/*.o
ranlib libcharset.a
The motive behind this trick is to let glib pick up libintl codes from another library archive libcharset.a that is used at the same time as libintl.