Try   HackMD

How to do cross-compiling using MinGW?

1. Prepare a pkg-config wrapper

  • Create sysroot for MinGW. For example, create a folder named $HOME/mingw-sysroot

  • Create ${CHOST}-pkg-config wrapper. The wrapper will set PKG_CONFIG_SYSROOT_DIR as sysroot.

#!/bin/sh

# Point to your sysroot.
SYSROOT=$HOME/mingw-sysroot

export PKG_CONFIG_DIR=
export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}

exec pkg-config "$@"
  • Export PKG_CONFIG as your wrapper.
export PKG_CONFIG=${CHOST}-pkg-config

2. Config with new sysroot.

./configure --host=i686-w64-mingw32 \
            --prefix=/usr \
            --with-sysroot=$HOME/mingw-sysroot
  1. Make and install.
make install DESTDIR=$HOME/mingw-sysroot

Reference: