How to cross compile Expat XML Parser - Step by Step Guide
Introduction
This tutorial introduces the way to cross compile the Expat XML Parser on a GNU Linux embedded platform. The host machine will be a PC on with a GNU Linux distribution installed.
The embedded platform might be constructed on top of one of the following architectures: arm, mips, mipsel, ppc or sparc.
The web site dealing with the Expat XML Parser can be reached at: http://www.libexpat.org/.
The latest available release at the time of writing of this tutorial is 2.0.1 (June 05 2007).
The project is referenced in sourceforge at: http://expat.sourceforge.net/.
Anyone wishing to download any release of the project can do that at: http://sourceforge.net/project/showfiles.php?group_id=10127.
Release 2.0.1 can be downloaded by typing the following command:
wget http://downloads.sourceforge.net/expat/expat-2.0.1.tar.gz
Overview
Expat is an XML parser library written in C. It is a stream-oriented parser in which an application registers handlers for things the parser might in the XML document (like start lags).
Prerequisites
To cross compile the Expat XML Parser, you need either a cross compiler, or an emulated Linux running on top of a virtualization software such as QEMU, matching your specific target platform.
If you wish to build yourself such a cross compiler, you should read the crosstool tutorial. There you will find all the information you need in order to build a C, C++ 4.1 GNU compiler for an ARM platform.
If you prefer to setup an ARM Debian system on top of a traditional Ubuntun distro (after all you are an hacker, aren't you?), have a look at How to setup an ARM Debian on Ubuntu tutorial in this wiki.
In general, Expat does not need specific dependencies.
Cross compilation process
Option I:Using a cross compiler
Assumptions
During the process, we will refer to the cross toolchain with xxx-yyy-linux-gnu
prefix. For example, the C compiler is called xxx-yyy-linux-gnu-gcc. That is applied on all the tools and utilities such gcc, g++, ar, ld, etc.
We will also assume that bin, include, lib
and libexec
folders of the cross toolchain are accessible through the PATH
variable environment in order to work with the compilers from any place in the file system.
Finally, we assume that it is intalled in the following folder:
/opt/crosstool/gcc-4.1.2-glibc-2.3.2/xxx-yyy-linux-gnu.
Organization
As mentioned above, the release being cross compiled is 2.0.1.
The tar.gz file will then be extracted under the /opt/external_packages/expat/2.0.1/source
folder and the results of the compilation will be stored under /opt/external_packages/expat/2.0.1/compiled/xxx-yyy-linux-gnu
folder.
The files resulting from the cross compilation are listed here:
.: total 16 drwxr-xr-x 2 root root 4096 2008-01-10 16:38 bin drwxr-xr-x 2 root root 4096 2008-01-10 16:38 include drwxr-xr-x 2 root root 4096 2008-01-10 16:38 lib drwxr-xr-x 3 root root 4096 2008-01-10 16:38 man
./bin: total 56 -rwxr-xr-x 1 root root 52991 2008-01-10 16:38 xmlwf
./include: total 44 -rw-r--r-- 1 root root 3364 2008-01-10 16:38 expat_external.h -rw-r--r-- 1 root root 40339 2008-01-10 16:38 expat.h
./lib: total 740 -rw-r--r-- 1 root root 390836 2008-01-10 16:38 libexpat.a -rwxr-xr-x 1 root root 851 2008-01-10 16:38 libexpat.la lrwxrwxrwx 1 root root 17 2008-01-10 16:38 libexpat.so -> libexpat.so.1.5.2 lrwxrwxrwx 1 root root 17 2008-01-10 16:38 libexpat.so.1 -> libexpat.so.1.5.2 -rwxr-xr-x 1 root root 351650 2008-01-10 16:38 libexpat.so.1.5.2
./man: total 4 drwxr-xr-x 2 root root 4096 2008-01-10 16:38 man1
./man/man1: total 8 -rw-r--r-- 1 root root 7895 2008-01-10 16:38 xmlwf.1
Cross compilation
Step 1
Install the expat software by untaring it in /opt/external_packages/expat/2.0.1/source
folder and then cd
to this directory.
Note: All the directories and files listed below must be moved from expat-2.0.1
folder to the parent folder (/opt/external_packages/expat/2.0.1/source
)
amiga Changes configure.in COPYING examples expat.dsw Makefile.in README vms xmlwf bcb5 configure conftools doc expat_config.h.in lib MANIFEST tests win32
Step 2
We will cross compile expat with its default parameters so we will configure it by typing:
./configure --host=xxx-yyy-linux-gnu --prefix=/opt/external_packages/expat/2.0.1/compiled/xxx-yyy-linux-gnu
Step 3
To compile and install expat, type successively make
and make install
. You should find the directories and files listed above under /opt/external_packages/expat/2.0.1/compiled/xxx-yyy-linux-gnu
.
Option II: Using QEMU
This section is not yet available.
Download
- arm-expat-2.0.1-tar.gz
You may consult this section if you want to download the Expat XML parser already cross compiled for your target platform if it is available. You can also contribute to expand the crosscompile.org community by uploading your own results in the case a given platform is not already supported.
Supported platforms
arm-unknown-linux-gnu
Written by David Sayada.