Skip to content

Instantly share code, notes, and snippets.

@cchantep
Last active March 10, 2016 14:02
Show Gist options
  • Save cchantep/9345d51889c0148c2256 to your computer and use it in GitHub Desktop.
Save cchantep/9345d51889c0148c2256 to your computer and use it in GitHub Desktop.
How to build glib 2.38.2 for winxp.

GLib for Windows XP

GLib is a core framework to build multi-platform application.

This is how to build its 2.38.2 version for Windows XP.

Prerequisites

  • Windows XP OS. For testing purposes, you can consider VM from IEVMS.
  • MSYS2 Base for i686 arch. By time this is written, I use msys2-base-i686-20140507.tar.xz.
  • GCC & make. If not installed in MSYS2, it can be done using pacman: pacman -S gcc make (I have built poppler using GCC 4.5.2 for compat).
  • Python 2.5+. Under MSYS2 it can be installed with pacman -S python (with that, I currently have Python 3).
  • ZLib, FFI & gettext (pacman -S zlib-devel libffi-devel gettext-devel).

In MSYS2 launched using its mingw32_shell; Let's build it.

  1. Download sources for GLib 2.38.2: cd tmp && wget http://sources/url. I can't build more recent version on winxp.
  2. Extract thoses sources: xz -dv glib-2.38.2.tar.xz && tar -xvf glib-2.38.2.tar.
  3. In sources directory, configure it: cd glib-2.38.2 && CPPFLAGS="-march=i686 -D_WIN32_WINNT=0x0501" ./configure --prefix=/usr --with-python=$(which python).
    • CPPFLAGS="-march=i686 -D_WIN32_WINNT=0x0501" is required to ensure OS is properly detected while building GLib.
  4. Then finally make it: make install (or just make if you don't want to install it).
@mingwandroid
Copy link

Hi,

I'm one of the MSYS2 developers and spotted this gist. Thanks for using our software!

I'd be careful about the difference between MSYS2 binaries and MinGW-w64 binaries here.

The zlib-devel libffi-devel and gettext-devel packages you install are MSYS2, but I assume the main goal here is to build glib for MinGW-w64 32bit?

If you do

pacman -Ss gettext

you will see that there are many gettext packages:

mingw32/mingw-w64-i686-gettext 0.18.3.2-3 (mingw-w64-i686) [installed]
GNU internationalization library (mingw-w64)
mingw64/mingw-w64-x86_64-gettext 0.18.3.2-3 (mingw-w64-x86_64) [installed]
GNU internationalization library (mingw-w64)
msys/gettext 0.18.3.2-1 (base-devel) [installed]
GNU internationalization library
msys/gettext-devel 0.18.3.2-1 (development) [installed]
GNU Internationalization development utilities
msys/libgettextpo 0.18.3.2-1 (libraries) [installed]
GNU Internationalization runtime library
msys/perl-Locale-Gettext 1.05-2 (perl-modules) [installed]
Permits access from Perl to the gettext() family of functions

The ones from the msys repository are probably not the ones that you want.

The same is true for the GCC you are installing, instead of the msys gcc package, you probably want to install the MinGW-w64 (32bit) package group mingw-w64-i686-toolchain.

@cchantep
Copy link
Author

Hi, I do use toolchain package on purpose, as it raise many dependencies which can be unwanted to build for winxp.

@mingwandroid
Copy link

Ok, but you are using MSYS2 GCC (and MSYS2 packages) which doesn't generate anything except MSYS2 executables, which are quite similar to Cygwin executables.

What is your goal here? To build Glib for Windows XP 32bit or to build Glib for Windows MSYS2 32bit? They are two very different things.

@Globik
Copy link

Globik commented Jan 29, 2016

Hallo mingwandroid,
I am on windows32 bit, my goal is to build the Janus webrtc gateway for Windows 32 bit. How to properly to build Glib with msys2?

@giograno
Copy link

Following your guide, I have the following error.

In file included from gconvert.c:35:0:
win_iconv.c: In function 'win_iconv_open':
win_iconv.c:792:18: error: '_errno' undeclared (first use in this function)
     cd->_errno = _errno;
                  ^
win_iconv.c:792:18: note: each undeclared identifier is reported only once for each function it appears in
win_iconv.c: In function 'make_csconv':
win_iconv.c:914:9: error: implicit declaration of function '_stricmp' [-Werror=implicit-function-declaration]
         if (_stricmp(p + 2, "nocompat") == 0)
         ^
win_iconv.c: In function 'name_to_codepage':
win_iconv.c:1007:5: error: implicit declaration of function '_strnicmp' [-Werror=implicit-function-declaration]
     else if (_strnicmp(name, "cp", 2) == 0)
     ^
cc1: some warnings being treated as errors

Could you please help me to resolve these errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment