I am in the process of cross-compiling Fontconfig for Windows using Mingw-w64 (the host is Ubuntu 12.04 64-bit). The process consists of the following steps:
Compile and install the build dependencies (Freetype and eXpat).
Run ./configure
:
./configure --host=i686-win64-mingw32 --prefix=/usr/i686-w64-mingw32
The ./configure
process completes without error and I run make
:
make
Unfortunately something goes wrong here:
...
CCLD libfontconfig.la
i686-w64-mingw32-gcc: error: /usr/i686-w64-mingw32/lib/libexpat.lib:
No such file or directory
As you can see, libtool
is looking for libexpat.lib
for some strange reason (which doesn't exist) instead of libexpat.a
(which does exist).
What's going on here?
Edit: to make things more confusing, these same steps work perfectly on Ubuntu 12.10 (Quantal). I have no clue why it's failing on 12.04 (Precise). A diff
of the output from the commands above yields no difference until the line containing the error above.
Further edit: I've extracted the raw command being run that generates the error:
/bin/bash ../libtool --silent --tag=CC --mode=link i686-w64-mingw32-gcc -O2 -ve
rsion-info 7:2:6 -no-undefined -export-symbols fontconfig.def -o libfontconfig.l
a -rpath /usr/i686-w64-mingw32/lib fcatomic.lo fcblanks.lo fccache.lo fccfg.lo
fccharset.lo fcdbg.lo fcdefault.lo fcdir.lo fcformat.lo fcfreetype.lo fcfs.lo fc
init.lo fclang.lo fclist.lo fcmatch.lo fcmatrix.lo fcname.lo fcpat.lo fcserializ
e.lo fcstat.lo fcstr.lo fcxml.lo ftglue.lo -L/usr/i686-w64-mingw32/lib -lfreetyp
e -L/usr/i686-w64-mingw32/lib -lexpat
The call to i686-w64-mingw32-gcc
becomes:
--------------------------------------------------------------------------------
i686-w64-mingw32-gcc -shared .libs/libfontconfig-1.dll.def .libs/fcatomic.o .lib
s/fcblanks.o .libs/fccache.o .libs/fccfg.o .libs/fccharset.o .libs/fcdbg.o .libs
/fcdefault.o .libs/fcdir.o .libs/fcformat.o .libs/fcfreetype.o .libs/fcfs.o .lib
s/fcinit.o .libs/fclang.o .libs/fclist.o .libs/fcmatch.o .libs/fcmatrix.o .libs/
fcname.o .libs/fcpat.o .libs/fcserialize.o .libs/fcstat.o .libs/fcstr.o .libs/fc
xml.o .libs/ftglue.o -L/usr/i686-w64-mingw32/lib /usr/i686-w64-mingw32/lib/libfr
eetype.dll.a /usr/i686-w64-mingw32/lib/libexpat.lib -O2 -o .libs/libfontconfig-1
.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libfontco
nfig.dll.a
So it turns out the problem wasn't with Fontconfig at all but with eXpat. The environment used to build eXpat didn't have Mingw-w64's C++ compiler installed and for some reason that resulted in a file named libexpat.a
instead of libexpat.dll.a
.
Once I retried the build with the g++-mingw-w64 package installed, it succeeded.
Incidentally, the reason that the Quantal build succeeded while the Precise build failed is due to the fact that g++-mingw-w64 is not a dependency of mingw-w64 on Precise but has become a dependency on Quantal.