cross-compilingconfiguremingw-w64libffi

libffi installed and recogonized by pkg-config, but not by glib


I want to cross compile glib for Windows. configure throws this error:

configure: WARNING: using cross tools not prefixed with host triplet configure: error: Package requirements (libffi >= 3.0.0) were not met:

No package 'libffi' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBFFI_CFLAGS and LIBFFI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.

However pkg-config --modversion libffi prints "3.1". I've installed both libffi and libffi-dev from the debian jessie repository.

(I'm not sure whether this might belong on superuser as it is also about package problems)


Solution

  • Checkout the steps to Bootstrap GLIB with MinGW


    1. Essentially one needs to first Download the source, build and install libffi

    cd /path/to/libffi/source
    mkdir bld
    cd bld
    ../configure --prefix=/mingw
    make && make install
    

    2. ...followed by building glib without PKG_CONFIG

    cd /path/to/glib/source
    mkdir bld
    cd bld
    export LIBFFI_CFLAGS='-I /mingw/lib/libffi-VERSION/include'
        VERSION is to be replaced with whatever version you built above.
        For me VERSION is 3.0.10.
    export LIBFFI_LIBS=-lffi
    export lt_cv_deplibs_check_method="pass_all"
    export CFLAGS=”O0 -g -pipe -Wall -march=i486 -mms-bitfields -mthreads”
    export CPPFLAGS=”-DG_ATOMIC_OP_USE_GCC_BUILTINS=1”
    export LDFLAGS=”-Wl,--enable-auto-image-base”
    ../configure --prefix=/mingw --with-pcre=internal --disable-static --disable-gtk-doc --enable-silent-rules
    make
    make install
    

    3. Subsequently, pkg_config can be built and installed.

    4. Then glib can be rebuilt normally as follows:

    cd /path/to/glib/source/bld
    make clean
    ../configure --prefix=/mingw
    make
    make install