Skip to content

Instantly share code, notes, and snippets.

@ablaette
Last active March 23, 2017 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ablaette/dc43b7f916121da7e6d15999e4bacf00 to your computer and use it in GitHub Desktop.
Save ablaette/dc43b7f916121da7e6d15999e4bacf00 to your computer and use it in GitHub Desktop.
Cross-compiling the Corpus Workbench (CWB) for 64bit/x86

Please note: This is not a perfect instruction for reproduction, I needed to reconstruct a few steps from memory. It will hopefully help future efforts to cross compile the CWB.

Cross compilation of Corpus Workbench for 64 bit Windows

Potentially useful resources

https://mlocati.github.io/articles/gettext-iconv-windows.html (libiconv-2.dll and libintl-8.dll)

http://www.dlldownloader.com/libglib2-00-dll/ (libglib-2.0-0.dll)

www.blogcompiler.com/2010/07/11/compile-for-windows-on-linux (A very good description)

INSTALL.WIN script in the cwb directory with installation files is extremely helpful up to the point where it comes to cross-compiling glib.

Preparations

Installation of x86_64-w64-mingw32-gcc on a Linux machine.

To get the installation directory for cross-compilation:

MINGW_OUTPUT_TMP=`x86_64-w64-mingw32-gcc --print-search-dirs | grep ^install`; echo ${MINGW_OUTPUT_TMP:9}

This line is from the INSTALL.WIN instructions.

Cross-compiling pcre

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar xzfv
cd pcre-DIR
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc  ./configure             \
         --host=x86_64-w64-mingw32                                  \
         --enable-utf8 --enable-unicode-properties --enable-jit     \
         --enable-newline-is-any --disable-cpp --enable-static      \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/              \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/         \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8//include

libiconv

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar xzfv libiconv-1.15.tar.gz
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc                            \
./configure                                                           \
         --host=x86_64-w64-mingw32                                    \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/                \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/           \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include
make 
sudo make install

expat

Thought this was necessary for gettext - but I am not really sure.

wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar xzfv expat-2.1.0.tar.gz
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc                            \
./configure                                                           \
         --host=x86_64-w64-mingw32                                    \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/                \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/           \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include
make 
sudo make install

gettext

This cost me a lot of nerves and it was painful. At the end it simply worked, but I do not know why.

wget http://ftp.gnu.org/pub/gnu/gettext/gettext-latest.tar.gz
tar xzfv gettext-latest.tar.gz
cd gettext-0.19.8.1/
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc                            \
./configure                                                           \
         --host=x86_64-w64-mingw32                                    \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/                \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/           \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include
make
sudo make install

libffi

wget ftp://sourceware.org/pub/libffi/libffi-3.2.tar.gz
tar xzfv libffi-3.2.tar.gz
cd libffi-3.2
LIBFFI_CFLAGS=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include             \
LIBFFI_LIBS=/usr/lib/gcc/x86_64-w64-mingw32/4.8/lib                   \
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc                            \
./configure                                                           \
         --host=x86_64-w64-mingw32                                    \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/                \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/           \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include
make 
sudo make install

Cross-compiling glib

It never worked to do it myself. Here you can get binaries in a simple and dirty way: BEST CHOICE!!

wget http://ftp.gnome.org/pub/gnome/binaries/win64/glib/2.26/

Copy files to cross compiler dirs after download.

This is where I finally got libglib-2.0.0.dll:

wget http://ftp.gnome.org/pub/gnome/binaries/win64/glib/2.26/glib_2.26.0-1_win64.zip

This is the effort to cross compile glib myself - it always failed, which seems to be a typical problem

wget http://ftp.gnome.org/pub/gnome/sources/glib/2.50/glib-2.50.0.tar.xz
tar xf glib-2.50.0.tar.xz
cd glib-2.50.0/
PATH=$PATH:/usr/lib/gcc/x86_64-w64-mingw32/4.8/bin
export PATH
CFLAGS="-I/usr/lib/gcc/x86_64-w64-mingw32/4.8/include"                \
LIBFFI_CFLAGS=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include             \
LIBFFI_LIBS=/usr/lib/gcc/x86_64-w64-mingw32/4.8/lib                   \
CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=gcc  ./configure               \
         --host=x86_64-w64-mingw32                                    \
         --prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/                \
         --exec-prefix=/usr/lib/gcc/x86_64-w64-mingw32/4.8/           \
         --oldincludedir=/usr/lib/gcc/x86_64-w64-mingw32/4.8/include

Cross compiling Corpus Workbench

Basically, I followed the instructions in the INSTALL.WIN file. In addition:

  • Got a fresh copy of CWB with svn
  • made the following changes in config.mk:
PLATFORM=mingw-cross
SITE=windows-release
# RELEASE_ARCH = x86_64 
CC = x86_64-w64-mingw32-gcc
LIBPCRE_DLL_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.8/bin
LIBGLIB_DLL_PATH=/usr/lib/gcc/x86_64-w64-mingw32/4.8/lib
  • in ./config/platform replaced every 'i586 ...' with 'x86_64-w64-mingw32'
CC = x86_64-w64-mingw32-gcc
LD = x86_64-w64-mingw32-ld
RC = x86_64-w64-mingw32-windres
AR = x86_64-w64-mingw32-ar cq
RANLIB = x86_64-w64-mingw32-ranlib
RELEASE_ARCH = x86
RELEASE_OS = windows
DEPEND = x86_64-w64-mingw32-gcc -MM -MG
  • used grep 'i586' for hunting

At the end, instructions of INSTALL-WIN again:

make clean
make depend
make all
make release

At the very end, I manipulated the package that is generated manually:

  • I put additional dlls / dependencies into the bin directory that might be missing.
  • I changed that *.bat file for the installation so that the target directory would be Program Files (x86) rathen than Program Files - to avoid that a 32 bit installation is written over

I think for 'make release', certain dlls were still missing (libglib-2.0.0.dll), so I downloaded that manually from a source indicated above and put that into the bin dir in the cross compiler directory.

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