| Building Xerces-C++ on Windows using Microsoft Visual C++ |
| Xerces-C++ source distribution comes with Microsoft Visual C++ projects and workspaces to help you build Xerces-C++. The following describes the steps you need to build Xerces-C++.
| Building Xerces-C++ library |
| To build Xerces-C++ from the source distribution (using MSVC), you will need to open the workspace containing the project. If you are building your application, you may want to add the Xerces-C++ project inside your application's workspace. The workspace containing the Xerces-C++ project file and all other samples is in: For MSVC Version 6:
    xerces-c-src2_7_0\Projects\Win32\VC6\xerces-all\xerces-all.dsw
For MSVC Version 7 (Visual C++.Net):
    xerces-c-src2_7_0\Projects\Win32\VC7\xerces-all\xerces-all.sln
Once you are inside MSVC, you need to build the project marked XercesLib. If you want to include the Xerces-C++ project separately, you need to pick up:
    (For MSVC V6) xerces-c-src2_7_0\Projects\Win32\VC6\xerces-all\XercesLib\XercesLib.dsp
    (For MSVC V7) xerces-c-src2_7_0\Projects\Win32\VC7\xerces-all\XercesLib\XercesLib.vcproj
You must make sure that you are linking your application with the xerces-c_2.lib library and also make sure that the associated DLL is somewhere in your path.
| If you are working on the AlphaWorks version which uses ICU, you must have the ICU data DLL named `icudata.dll` available from your path setting. For finding out where you can get ICU from and build it, look at the How to Build ICU.
| Building samples |
| If you are using the source package, inside the same workspace (xerces-all.dsw), you'll find several other projects. These are for the samples. Select all the samples and right click on the selection. Then choose "Build (selection only)" to build all the samples in one shot. If you are using the binary package, load the xerces-c2_7_0-win32\samples\Projects\Win32\VC6\samples.dsw Microsoft Visual C++ workspace inside your MSVC IDE. Then select all the samples and right click on the selection. Then choose "Build (selection only)" to build all the samples in one shot.
| Building Xerces-C++ 64 bit binary on Windows XP using Intel C++ Compiler |
| Xerces-C++ source distribution comes with Microsoft Visual C++ NMake Files which work with Intel C++ Compiler. The following describes the steps you need to build Xerces-C++ 64 bit binary using Intel C++ Compiler.
| Building Xerces-C++ library |
| Xerces-C++ source distribution provides a makefile `all.mak` which will build everything including samples, tests and the parser library.
    cd xerces-c-src2_7_0\Projects\Win32\VC6\xerces-all\all
    nmake -f all.mak "CFG=all - Win64 Release" CPP=ecl.exe
If you want to just build the Xerces-C++ parser library alone, then
    cd xerces-c-src2_7_0\Projects\Win32\VC6\xerces-all\XercesLib
    nmake -f XercesLib.mak "CFG=XercesLib - Win64 Release" CPP=ecl.exe
You must make sure that you are linking your application with the xerces-c_2.lib library and also make sure that the associated DLL is somewhere in your path.
| Building Xerces-C++ on Windows using Borland C++Builder |
| Xerces-C++ source distribution comes with Borland C++Builder6 projects to help you build Xerces-C++. The following describes the steps you need to build Xerces-C++.
| Building Xerces-C++ library |
| The library and demo projects are all contained in the Xerces-all project group: xerces-c-src2_7_0\Projects\Win32\BCB6\Xerces-all\Xerces-all.bpg Each project in the group refers a directory below \Xerces-all. For example, the XercesLib project files are contained in the directory xerces-c-src2_7_0\Projects\Win32\BCB6\Xerces-all\XercesLib To build any project, open the project manager. Double click on the project name. Then select "Project|Build" from the menu. For example, double click on XercesLib.dll in the manager. Then select "Project|Build XercesLib" from the menu. Once the library has been built, include XercesLib.lib with in application's project and place XercesLib.dll somewhere in your path.
| Building Xerces-C++ on Windows using Borland C++ Compiler |
| Xerces-C++ source distribution comes with Borland C++ Compiler make files to help you build Xerces-C++. The following describes the steps you need to build Xerces-C++. Change directory to `xerces-c-src2_7_0\Projects\Win32\BCC.551\Xerces-all` Run `MakeBuildDirs.bat`. Then issue `make -f Xerces-all.mak` to build the dll (without deprecated DOM API) and tests, or `make -f Xerces-all.mak -DWITHDEPRDOM=Y` to build the dll with deprecated DOM API (approx. 300k larger) and tests
| Building Xerces-C++ on Windows using Cygwin |
| Do not jump into the build directly before reading this. Xerces-C++ may be built in the Cygwin environment for use by Cygwin applications. As with the UNIX platforms, Xerces-C++ on Cygwin uses GNU tools. Therefore, with a couple of notable exceptions, Xerces-C++ on Cygwin is built using the same instructions as the UNIX platforms. The build environment variable XERCESCROOT must be set to the proper path containing the Xerces-C++ sources and runConfigure must be run with the "-pcygwin -cgcc -xg++" arguments. Note that Cygwin is different from the UNIX platforms in the way that it finds libraries at run time. While UNIX platforms may use the environment variable LD_LIBRARY_PATH, Cygwin uses the PATH environment variable. There is an issue with the gcc/g++ compiler version 2.95, where C++ exceptions thrown from a dll will cause the application to crash, regardless of whether there is a "catch" statement. This bug doesn't occur in tests using gcc 3.1 or 3.2, so it is recommended that you use gcc 3.1 or higher.
| Building Xerces-C++ on UNIX platforms |
| Xerces-C++ uses GNU tools like Autoconf and GNU Make to build the system. You must first make sure you have these tools installed on your system before proceeding. If you do not have required tools, ask your system administrator to get them for you. These tools are free under the GNU Public License and may be obtained from the Free Software Foundation. Do not jump into the build directly before reading this. Spending some time reading the following instructions will save you a lot of wasted time and support-related e-mail communication. The Xerces-C++ build instructions are a little different from normal product builds. Specifically, there are some wrapper-scripts that have been written to make life easier for you. You are free not to use these scripts and use Autoconf and GNU Make directly, but we want to make sure you know what you are by-passing and what risks you are taking. So read the following instructions carefully before attempting to build it yourself. Besides having all necessary build tools, you also need to know what compilers we have tested Xerces-C++ on. The following table lists the relevant platforms and compilers.
Operating System | Compiler
32-bit binary |
Windows 2000 | MS Visual C++ 6.0 SP3
AIX 5.1 | xlC_r 6.0.0
Solaris 2.8 | Forte C++ Version 6 Update 2
HP-UX 11i | aCC A.03.52 with pthreads
RHEL 4.0 (IA32) | gcc 3.4.3
64-bit binary |
AIX 5.1 | xlC_r 6.0.0
Solaris 2.8 | Forte C++ Version 6 Update 2
HP-UX 11i | aCC A.03.52 with pthreads
SuSE Linux 8.0 (AMD64) | gcc 3.2.2
If you are not using any of these compilers, you are taking a calculated risk by exploring new grounds. Your effort in making Xerces-C++ work on this new compiler is greatly appreciated and any problems you face can be addressed on the Xerces-C++ user mailing list. Differences between the UNIX platforms: The description below is generic, but as every programmer is aware, there are minor differences within the various UNIX flavors the world has been bestowed with. The one difference that you need to watch out in the discussion below, pertains to the system environment variable for finding libraries. On Linux and Solaris, the environment variable name is called `LD_LIBRARY_PATH`, on AIX it is `LIBPATH`, on Mac OS X it is `DYLD_LIBRARY_PATH`, while on HP-UX it is `SHLIB_PATH`. The following discussion assumes you are working on Linux, but it is with subtle understanding that you know how to interpret it for the other UNIX flavors.
| If you wish to build Xerces-C++ with ICU, look at the Building Xerces-C++ with ICU. It tells you where you can get ICU and how to build Xerces-C++ with it.
| Setting build environment variables |
| Before doing the build, you must first set your environment variables to pick-up the compiler and also specify where you extracted Xerces-C++ on your machine. While the first one is probably set for you by the system administrator, just make sure you can invoke the compiler. You may do so by typing the compiler invocation command without any parameters (e.g. xlc_r, or g++, or cc) and check if you get a proper response back. Next set your Xerces-C++ root path as follows:
    export XERCESCROOT=<full path to xerces-c-src2_7_0>
This should be the full path of the directory where you extracted Xerces-C++.
| Building Xerces-C++ library |
| As mentioned earlier, to build Xerces-C++ from the source distribution, you must be ready with the GNU tools like autoconf and gmake before you attempt the build. The autoconf tool is required on only one platform and produces a set of portable scripts (configure) that you can run on all other platforms without actually having the autoconf tool installed everywhere. In all probability the autoconf-generated script (called `configure`) is already in your `src/xercesc` directory. If not, type:
    cd $XERCESCROOT/src/xercesc
    autoconf
This generates a shell-script called `configure`. It is tempting to run this script directly as is normally the case, but wait a minute. Even if you are using the default compilers like gcc and g++ you need to export a few more environment variables before you can invoke configure. Rather than make you to figure out what strange environment variables you need to use, we have provided you with a wrapper script that does the job for you. All you need to tell the script is what your compiler is, and what options you are going to use inside your build, and the script does everything for you. Here is what the script takes as input:
    runConfigure: Helper script to run "configure" for one of the supported platforms
    Usage: runConfigure "options"
           where options may be any of the following:
           -p <platform> (accepts 'aix', 'linux', 'freebsd',
                'netbsd', 'solaris', 'hp-10', 'hp-11', 'openserver', 'unixware',
                'os400', 'irix', 'ptx', 'tru64', 'macosx, 'cygwin', 'qnx')
                [required: no default]
           -c <C compiler name> (e.g. gcc, cc, xlc_r, icc or ecc)
                [default is make default; cc for gnu make]
           -x <C++ compiler name> (e.g. g++, CC, aCC, xlC_r, QCC
                icc or ecc) [default is make default; g++ for gnu make]
           -d (specifies that you want to build debug version)
                [default: no debug]
           -m <message loader> can be 'inmem', 'icu', 'MsgFile' or
                'iconv' [default: inmem]
           -n <net accessor> can be 'fileonly', 'libwww', 'socket' or
                'native' [default: socket]
           -t <transcoder> can be 'icu', 'Iconv400', 'Uniconv390',
                 'IconvFBSD', 'IconvGNU' or 'native'
                 [default: native]
           -r <thread option>  can be 'pthread' or 'dce'
                 (AIX, HP-11, and Solaris) or  'sproc' (IRIX) or 'none'
                 [default: pthread]
           -b <bitsToBuild> (accepts '64', '32') [default: 32]
           -l <extra linker options>
           -z <extra compiler options>
           -P <install-prefix>
           -C <any one extra configure options>
           -h (get help on the above commands)
| Xerces-C++ can be built as either a standalone library or as a library dependent on International Components for Unicode (ICU). For simplicity, the following discussion only explains standalone builds.
Some additional explanation may be helpful for some of the options: -m <message loader>, -t <transcoder> If you specify `icu` as the value for either of these options, you must already have set the environment variable ICUROOT -n <net accessor> The default value `socket` handles HTTP URL's. The value `native` is only supported for macosx. One of the common ways to build Xerces-C++ is as follows:
    runConfigure -plinux -cgcc -xg++ -minmem -nsocket -tnative -rpthread
The response will be something like the following (extra line breaks have been added for readability). See especially the end, which tells you how configure was invoked.
    Generating makefiles with the following options ...
    Platform: linux
    C Compiler: gcc
    C++ Compiler: g++
    Message Loader: inmem
    Net Accessor: socket
    Transcoder: native
    Thread option: pthread
    bitsToBuild option: 32
    Extra compile options:
    Extra link options:
    Extra configure options:
    Debug is OFF

    creating cache ./config.cache
    checking for gcc... gcc
    checking whether the C compiler
      (gcc   -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER -DXML_USE_PTHREADS
             -DXML_USE_NETACCESSOR_SOCKET       ) works... yes
    checking whether the C compiler
      (gcc   -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER -DXML_USE_PTHREADS
             -DXML_USE_NETACCESSOR_SOCKET       ) is a cross-compiler... no
    checking whether we are using GNU C... yes
    checking whether gcc accepts -g... yes
    checking for c++... g++
    checking whether the C++ compiler
      (g++   -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER -DXML_USE_PTHREADS
             -DXML_USE_NETACCESSOR_SOCKET      ) works... yes
    checking whether the C++ compiler
      (g++   -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER -DXML_USE_PTHREADS
             -DXML_USE_NETACCESSOR_SOCKET      ) is a cross-compiler... yes
    checking whether we are using GNU C++... yes
    checking whether g++ accepts -g... yes
    checking for a BSD compatible install... /usr/bin/install -c
    checking for autoconf... autoconf
    checking how to run the C preprocessor... gcc -E
    checking for ANSI C header files... yes
    checking for XMLByte... no
    checking host system type... i686-pc-linux-gnu
    updating cache ./config.cache
    creating ./config.status
    creating Makefile
    creating util/Makefile
    creating util/Transcoders/ICU/Makefile
    creating util/Transcoders/Iconv/Makefile
    creating util/Transcoders/Iconv390/Makefile
    creating util/Transcoders/Uniconv390/Makefile
    creating util/Transcoders/Iconv400/Makefile
    creating util/Transcoders/IconvFBSD/Makefile
    creating util/Transcoders/MacOSUnicodeConverter/Makefile
    creating util/Platforms/Makefile
    creating util/Platforms/Solaris/Makefile
    creating util/Platforms/AIX/Makefile
    creating util/Platforms/Linux/Makefile
    creating util/Platforms/FreeBSD/Makefile
    creating util/Platforms/HPUX/Makefile
    creating util/Platforms/OS390/Makefile
    creating util/Platforms/OS400/Makefile
    creating util/Platforms/IRIX/Makefile
    creating util/Platforms/PTX/Makefile
    creating util/Platforms/OpenServer/Makefile
    creating util/Platforms/UnixWare/Makefile
    creating util/Platforms/Tru64/Makefile
    creating util/Platforms/MacOS/Makefile
    creating util/Compilers/Makefile
    creating util/MsgLoaders/InMemory/Makefile
    creating util/MsgLoaders/ICU/Makefile
    creating util/MsgLoaders/MsgCatalog/Makefile
    creating util/MsgLoaders/MsgFile/Makefile
    creating util/NetAccessors/Socket/Makefile
    creating util/NetAccessors/libWWW/Makefile
    creating util/NetAccessors/MacOSURLAccessCF/Makefile
    creating util/regx/Makefile
    creating validators/Makefile
    creating validators/common/Makefile
    creating validators/datatype/Makefile
    creating validators/DTD/Makefile
    creating validators/schema/Makefile
    creating validators/schema/identity/Makefile
    creating framework/Makefile
    creating dom/Makefile
    creating dom/impl/Makefile
    creating dom/deprecated/Makefile
    creating parsers/Makefile
    creating internal/Makefile
    creating sax/Makefile
    creating sax2/Makefile
    creating ../../obj/Makefile

    Having build problems?
    Read instructions at http://xml.apache.org/xerces-c/build.html
    Still cannot resolve it?
    Find out if someone else had the same problem before.
    Go to http://marc.theaimsgroup.com/?l=xerces-c-dev

    In future, you may also directly type the following commands to create the Makefiles.

    export TRANSCODER="NATIVE"
    export MESSAGELOADER="INMEM"
    export NETACCESSOR="Socket"
    export THREADS="pthread"
    export BITSTOBUILD="32"
    export CC="gcc"
    export CXX="g++"
    export CXXFLAGS=" -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER
                      -DXML_USE_PTHREADS -DXML_USE_NETACCESSOR_SOCKET "
    export CFLAGS=" -w -O -DXML_USE_NATIVE_TRANSCODER -DXML_USE_INMEM_MESSAGELOADER
                    -DXML_USE_PTHREADS -DXML_USE_NETACCESSOR_SOCKET "
    export LDFLAGS=" "
    export LIBS=" -lpthread "
    configure

    If the result of the above commands look OK to you, go to the directory
    $HOME/xerces-c-src2_7_0/src/xercesc and type "gmake" to make the XERCES-C system.
So now you see what the wrapper script has actually been doing! It has invoked `configure` to create the Makefiles in the individual sub-directories, but in addition to that, it has set a few environment variables to correctly configure your compiler and compiler flags too. Now that the Makefiles are all created, you are ready to do the actual build.
    gmake
Is that it? Yes, that's all you need to build Xerces-C++.
| Building samples |
| The installation process for the samples is same on all UNIX platforms.
    cd xerces-c2_7_0-linux/samples
    ./runConfigure -p<platform> -c<C_compiler> -x<C++_compiler>
    gmake
This will create the object files in each sample directory and the executables in ' xerces-c2_7_0-linux/bin' directory. Note that runConfigure is just a helper script and you are free to use ./configure with the correct parameters to make it work on any platform-compiler combination of your choice. The script needs the following parameters:
    runConfigure: Helper script to run "configure" for one of the supported platforms
    Usage: runConfigure "options"
           where options may be any of the following:
           -p <platform> (accepts 'aix', 'beos', 'linux', 'freebsd', 'netbsd',
                     'solaris', 'hp-10', 'hp-11', 'openserver', 'unixware',
                     'os400', 'irix', 'ptx', 'tru64', 'macosx', 'cygwin')
                     [required; no default]
           -c <C compiler name> (e.g. gcc, cc, xlc_r, icc or ecc)
                     [default is make default; cc for gnu make]
           -x <C++ compiler name> (e.g. g++, CC, aCC, xlC_r, QCC,
                     icc or ecc)  [default is make default; g++ for gnu make]
           -d (specifies that you want to build debug version) [default: not debug]
           -r <thread option> can be 'pthread' or 'dce'
                 (AIX, HP-11, and Solaris) or 'sproc' (IRIX) or 'none'
                 [default: pthread]
           -b <bitsToBuild> (accepts '64', '32') [default: 32]
           -l <extra linker options>
           -z <extra compiler options>
           -h (get help on the above commands)
| NOTE:The code samples in this section assume that you are working on the Linux binary drop. If you are using some other UNIX flavor, please replace '-linux' with the appropriate platform name in the code samples.
To delete all the generated object files and executables, type:
    gmake clean
| Building Xerces-C++ as a single-threaded library on Unix platforms |
| To build a single-threaded library on Unix platforms you have to update one or more of the following files `Makefile.incl, Makefile.in, runConfigure`. The following steps guide you to create a single-threaded library for each platform: For Aix - Replace `xlc_r` and `xlC_r` libraries with `xlc` and `xlC` respectively Replace `makeC++SharedLib_r` with `makeC++SharedLib` Remove the flag `-D_THREAD_SAFE` Remove inclusion of any threaded library directories from the `LIBPATH` Remove inclusion of `-lpthreads` and `-lpthread_compat` Add `-DAPP_NO_THREADS` to define the variable under AIX specific options in `Makefile.incl` For Solaris - Add `-DAPP_NO_THREADS` to define the variable under SOLARIS specific options in `Makefile.incl` Remove compiler switch `-mt` Remove `-D_REENTRANT` flag from the 'compile' options Remove inclusion of `-lpthread` For Linux - Add `-DAPP_NO_THREADS` to define the variable under LINUX specific options in `Makefile.incl` Remove `-D_REENTRANT` flag from the 'compile' options Remove inclusion of `-lpthread` For HPUX - Add `-DAPP_NO_THREADS` to define the variable under HP specific options in `Makefile.incl` Remove inclusion of `-lpthread` and `-lcma` Remove threading defines like `-D_PTHREADS_DRAFT4 , -DXML_USE_DCE`

Copyright © 1999-2005 The Apache Software Foundation. All Rights Reserved.