[xslt] Building XSLT on Windows using mingw

I am trying to build libxslt on Windows, using the mingw toolchain.
Unless I'm mistaken, it doesn't look like this approach is commonly
used, as there seem to be a number of problems with the mingw makefile
supplied. (Alternatively, it's quite possible that I'm doing something
wrong, but I *have* tried the process a number of times now, on a
couple of PCs, always with the same sort of issues). But even after
fixing all the problems I can (patch attached) I still have issues.
I'd appreciate any advice.

I am using the latest mingw, with gcc version 4.7.2, on Windows 7. I
have an essentially clean build environment (I've stripped everything
from PATH except the Windows directories and mingw\bin). I have
previously built zlib and libiconv using the msys/mingw toolchain, and
I have them in my C_INCLUDE_PATH and LIBRARY_PATH variables, so that
gcc will pick them up automatically.

I have built libxml, by means of the documented build process

cscript configure.js compiler=mingw zlib=yes prefix=foo
mingw32-make install

(There's one easily fixed problem here - the makefile needs a define
of HAVE_STDINT_H, which I guess is because gcc 4.7.2 is a later
version than the one the makefile was designed for, so now has the
header where it didn't before).

This gives me libxml in ...\libxml-2.9.0\win32\foo

Now, I go to libxslt-1.1.28\win32. In order to get a clean build, I
need to apply the attached patch. (One thing this does is include
attrvt.c into the build, which suggests to me that the mingw makefile
has been missed in some previous changes - I've compared with the MSVC
makefile template, though, and can't see any other obvious problems).

The patch adds the aforementioned attrvt.c, changes a few -llibxml2 to
the correct form for mingw, -lxml2, and reorders the link libraries
when building xsltproc so that the symbols are all resolved correctly
(ld only does one pass over the -l options to satisfy symbol

With this patch applied, and with
...\libxml-2.9.0\win32\foo\include\libxml2 added to C_INCLUDE_PATH and
...\libxml-2.9.0\win32\foo\lib added to LIBRARY_PATH (the include= and
lib= parameters to configure.js don't seem to make any difference), I
get the following error on building:

gcc.exe -DWIN32 -D_WINDOWS -D_MBCS -I.. -I..\libxslt -Ifoo\include
-DNDEBUG -O2  -c -o int.xslt.mingw/templates.o ..\libxslt/templates.c
gcc.exe -DWIN32 -D_WINDOWS -D_MBCS -I.. -I..\libxslt -Ifoo\include
-DNDEBUG -O2  -c -o int.xslt.mingw/transform.o ..\libxslt/transform.c
gcc.exe -DWIN32 -D_WINDOWS -D_MBCS -I.. -I..\libxslt -Ifoo\include
-DNDEBUG -O2  -c -o int.xslt.mingw/variables.o ..\libxslt/variables.c
gcc.exe -DWIN32 -D_WINDOWS -D_MBCS -I.. -I..\libxslt -Ifoo\include
-DNDEBUG -O2  -c -o int.xslt.mingw/xsltutils.o ..\libxslt/xsltutils.c
gcc.exe -Wl,-L,bin.mingw -Wl,-L,foo\lib  -shared -Wl,--dll
-Wl,--out-implib,bin.mingw/libxslt.lib -Wl,--major-image-version,1
-Wl,--minor-image-version,1 -o bin.mingw/libxslt.dll
int.xslt.mingw/attributes.o int.xslt.mingw/documents.o
int.xslt.mingw/extensions.o int.xslt.mingw/extra.o
int.xslt.mingw/functions.o int.xslt.mingw/imports.o
int.xslt.mingw/keys.o int.xslt.mingw/namespaces.o
int.xslt.mingw/numbers.o int.xslt.mingw/pattern.o
int.xslt.mingw/preproc.o int.xslt.mingw/security.o
int.xslt.mingw/templates.o int.xslt.mingw/transform.o
int.xslt.mingw/variables.o int.xslt.mingw/xslt.o
int.xslt.mingw/xsltlocale.o int.xslt.mingw/xsltutils.o
int.xslt.mingw/attrvt.o -lwsock32 -lxml2
int.xslt.mingw/attributes.o:attributes.c:(.text+0xb): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x1d8): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x239): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x380): undefined
reference to `_imp__xmlStringTextNoenc'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x492): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x557): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x5f4): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x6bc): undefined
reference to `_imp__xmlStringTextNoenc'
int.xslt.mingw/attributes.o:attributes.c:(.text+0x6e4): undefined
reference to `_imp__xmlMalloc'
int.xslt.mingw/attributes.o:attributes.c:(.text+0xa99): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0xb41): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0xd02): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o:attributes.c:(.text+0xd18): undefined
reference to `_imp__xmlFree'
int.xslt.mingw/attributes.o: bad reloc address 0x20 in section
collect2.exe: error: ld returned 1 exit status
Makefile:238: recipe for target 'bin.mingw\libxslt.dll' failed
mingw32-make: *** [bin.mingw\libxslt.dll] Error 1

This looks to me like some sort of mismatch in declspec settings. And
yet, there are no settings that I can see in configure.js (either
libxml's or libxslt's) that might affect this.

A couple of other points:

* I am doing my own build rather than using the binaries available
from Igor Zlatovic, as those link to iconv.dll, and the mingw/msys
toolchain I use for my other builds uses libiconv-2.dll. I have had
far too many programs crash from mismatched libiconv builds in the
past to want to deal with it again, hence my preference for building
my own copy with a matching libiconv.
* The error above didn't happen when I ran the build on my other PC
(which I don't have at hand at the moment to check). There may be
something subtly different in the environments of the two PCs, but (a)
I don't know what it might be, I've gone to great lengths to try to
get a minimal build environment, and (b) I'd really like to have a
reproducible build process, so I'd like to understand the cause in any

Can anyone offer any suggestions as to what might be going on? I've
been working on this for 2 or 3 days now, and I think I've gone as far
as I can on my own. Any suggestions would be very gratefully accepted.


Attachment: Makefile.mingw.patch
Description: Binary data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]