Home > Uncategorized > Cross building Xalan and Xerces for Mingw on Debian (2014 update)

Cross building Xalan and Xerces for Mingw on Debian (2014 update)

This is an update of this post.

dllwrap

Both xerces and xalan make files call dllwrap which cannot be found in a cross build environment. The real name of this command is <prefix>-dllwrap (ex: x86_64-w64-mingw32-dllwrap). I tried to create a dllwrap symlink, but I was not able to make dllwrap working at all. I fell back to the ld –out-implib flag which is what CMake use when creating dll with mingw. To do so without modifying xerces and xalan make files I created this wrapper:

#! /usr/bin/env python
import sys
import subprocess
for i in xrange(len(sys.argv)):
  if sys.argv[i] == '-o':
    output_index=i+1
    break
sys.argv.append("-Wl,--out-implib,%s.a" % sys.argv[output_index])
sys.argv[0]="x86_64-w64-mingw32-c++"
sys.argv.insert(1, "-shared")
sys.argv.remove('--export-all-symbols')
sys.argv.remove('--driver-name')
sys.argv.remove('c++')
print " ".join(sys.argv)
subprocess.call(sys.argv)

Then I just need to name this file dllwrap and ensure it’s in the PATH.

Xerces

The build instructions says to use set LDFLAGS=-no-undefined but even if this option is for libtool it’s also pass to g++ which will stop because it doesn’t know this option. A workaround is to run configure with -no-undefined then to manually change the Makefile after:

apt-get install g++-mingw-w64-x86-64
git clone https://github.com/apache/xerces-c.git
cd xerces-c
git checkout Xerces-C_3_1_1
./reconf
./configure --host x86_64-w64-mingw32 --prefix=/tmp/xerces-c-3.1.1
find . -name Makefile -exec sed -i 's/^LDFLAGS =/LDFLAGS = -no-undefined/g' {} \;
make && make install

Xalan

As mingw now provide the localtime_r function I needed to apply the following patch:

index c43e9df..47aa9b2 100644
--- a/src/xalanc/Include/GCCDefinitions.hpp
+++ b/src/xalanc/Include/GCCDefinitions.hpp
@@ -48,7 +48,6 @@
 #endif
 
 #if defined(__MINGW32__)
-#define XALAN_NO_REENTRANT_TIME_FUNCTIONS
 #define XALAN_WINDOWS_DIR_FUNCTIONS
 #define WINDOWS_THREAD_FUNCTIONS
 #else

Then the build is straightforward:

apt-get install g++-mingw-w64-x86-64
git clone https://github.com/apache/xalan-c.git
cd xalan-c
git checkout Xalan-C_1_11_0
export XALANCROOT=$PWD
export PATH=$PWD:$PATH
export XERCESCROOT=/tmp/xerces-c-3.1.1
./runConfigure -p cygwin -C--host -Cx86_64-w64-mingw32 -x x86_64-w64-mingw32-g++ -c x86_64-w64-mingw32-gcc -C--prefix=/tmp/xalanc-3.11
make

make install fail in bin/ because it doesn’t know how to handle the .exe extension but that’s enough for my usage.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: