Introduction
This guide shows how to build statically-linked Win32 XSD compiler with GCC-Mingw toolchain using the Cygwin environment. The resulting binary is supposed to be self-sufficient and can be used on other Win32 machines without installing Cygwin or copying any DLLs. The generated code can be compiled with other C++ compiler (e.g., Visual C++). The XSD runtime is a header-only library and does not need to be built. If you run into problems while following these instructions feel free to ask for help on the xsd-users mailing list.
Unfortunately, the stock libstdc++ (Standard C++ Library, part of g++) that comes with the Cygwin/Mingw environment is compiled without support for wchar_t. You can read more about this on the Mingw website. As a result, we will be using STLPort instead of libstdc++.
The build commands presented below assume that you download and build source code in your home directory. Adjust your paths accordingly if you are using a different directory.
Cygwin
Download Cygwin from the Cygwin website. When installing, make sure the following packages are selected:
Devel/gcc Devel/gcc-core Devel/gcc-g++ (3.4.4 or later) Devel/gcc-mingw-core Devel/gcc-mingw-g++ (3.4.4 or later) Devel/make Interpreters/m4 Shells/bash Util/bzip2
GNU make
Check the version of GNU make that comes with Cygwin by executing
make --version. If the version is lower than 3.81,
download GNU make 3.81 or later from the
GNU make website.
Then follow these build and installation instructions:
$ cd $ bzip -dc make-3.81.tar.bz2 | tar x $ cd make-3.81 $ ./configure $ make $ make install $ make --version GNU Make 3.81
Build
Download the latest build source release from the
build
project page. Then follow these installation instructions:
$ cd $ bzip2 -dc build-0.3.3.tar.bz2 | tar x $ cd build-0.3.3 $ make install install_prefix=/usr/local
Note that you need to install build in a location where GNU make
looks for included makefiles by default (normally
/usr/include and /usr/local/include).
Otherwise you will need to add the build include
directory to the make search list. For example, if you installed
build to /home/user/install, then the
following command will add the include directory in
this path to the make search list:
$ export MAKEFLAGS=-I/home/user/install/include
STLPort
Download STLPort version 5.0.1 with MinGW fixes (you can also try the latest version from the STLPort website, however, the following build instructions may not work). Then follow these build instructions:
$ cd $ bzip2 -dc STLport-5.0.1-mingw.tar.bz2 | tar x $ cd STLport-5.0.1/build/lib $ ./configure --no-cygwin $ make -f gcc.mak install-release-static
If you are using a fairly old version of Cygwin then you may get a few compilation errors that look like this:
.../winbase.h:1667: error: declaration of C function `LONG InterlockedDecrement(LONG*)' conflicts with .../_windows.h:167: error: previous declaration `long int InterlockedDecrement(volatile long int*)' here
If that's the case then you will need to open
STLport-5.0.1/stlport/stl_user_config.h
and comment out the definition of the _STLP_NEW_PLATFORM_SDK
macro with /* */. Then re-run
make -f gcc.mak install-release-static.
Boost-jam
Download the latest precompiled boost-jam binary for
Windows from the Boost website
(follow the "Download" link on the right). The package name will
be something like boost-jam-3.1.12-1-ntx86.zip. Then
follow these installation instructions:
$ cd $ unzip boost-jam-3.1.12-1-ntx86.zip $ cp boost-jam-3.1.12-1-ntx86/bjam.exe /usr/local/bin/ $ chmod ug+x /usr/local/bin/bjam $ bjam -v Boost.Jam Version 3.1.12. OS=NT.
Boost
Download Boost version 1.33.1 (you can also try the latest version from the Boost website, however, the following build instructions may not work). Then follow these build instructions:
$ cd $ bzip2 -dc boost_1_33_1.tar.bz2 | tar x $ cd boost_1_33_1/libs/filesystem/build/ $ bjam -sTOOLS=mingw-stlport "-sBUILD=release <runtime-link>static" \ "-sGXX=g++ -mno-cygwin -D_REENTRANT" \ -sSTLPORT_5.0.1_PATH=../../../../STLport-5.0.1 -sSTLPORT_VERSION=5.0.1 $ cd ../../regex/build $ bjam -sTOOLS=mingw-stlport "-sBUILD=release <runtime-link>static" \ "-sGXX=g++ -mno-cygwin -D_REENTRANT" \ -sSTLPORT_5.0.1_PATH=../../../../STLport-5.0.1 -sSTLPORT_VERSION=5.0.1 $ cd ../../../stage/lib/ $ ln -s libboost_filesystem-mgw-sp-1_33_1.lib libboost_filesystem-gcc-1_33_1.a $ ln -s libboost_regex-mgw-sp-1_33_1.lib libboost_regex-gcc-1_33_1.a
Xerces-C++
Download the latest Xerces-C++ source release from the Xerces-C++ download page. You have a choice of using Xerces-C++ 2-series (e.g., 2.8.0) or 3-series (e.g., 3.0.0). For XSD 3.2.0 or later Xerces-C++ 3-series is recommended.
For Xerces-C++ 3-series, follow these build instructions:
$ cd $ gzip -dc xerces-c-3.0.0.tar.gz | tar x $ cd xerces-c-3.0.0 $ ./configure --disable-threads --disable-network \ --enable-transcoder-windows --disable-shared --host=i686-mingw32msvc \ CXXFLAGS="-mno-cygwin -O2" CFLAGS="-mno-cygwin -O2" $ cd src $ make
For Xerces-C++ 2-series, follow these build instructions:
$ cd $ gzip -dc xerces-c-src_2_8_0.tar.gz | tar x $ export XERCESCROOT=~/xerces-c-src_2_8_0 $ cd xerces-c-src_2_8_0/src/xercesc $ ./runConfigure -p mingw-msys -c gcc -x g++ -n fileonly \ -r none -s -z -mno-cygwin -C --host=i686-mingw32 $ make
Libcult
Download the latest libcult source release from the
libcult
website. Then follow these build instructions:
$ cd $ bzip2 -dc libcult-1.4.2.tar.bz2 | tar x $ cd libcult-1.4.2 $ make Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: y Would you like the C++ compiler to generate debug information? [y]: n Embed dynamic library paths into executables (rpath)? [y]: n Please enter any extra C++ preprocessor options. []: -I ~/STLport-5.0.1/stlport -D_REENTRANT Please enter any extra C++ compiler options. []: -mno-cygwin Please enter any extra C++ linker options. []: -L ~/STLport-5.0.1/lib Please enter any extra C++ libraries. []: -lstlport.5.0 Would you like to build a multi-threaded version of 'libcult'? [y]: n Would you like to build the network subsystem of 'libcult'? [y]: n Would you like to build the data representation subsystem of 'libcult'? [y]: n Please select the default library type: (1) archive (2) shared object [2]: 1 Please enter the archiver (ar) binary you would like to use. [ar]: ar Please enter the indexer (ranlib) binary you would like to use. [ranlib]: ranlib Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Please select the optimization level you would like to use: [2]: 2
Libfrontend-elements
Download the latest libfrontend-elements source release
from the libfrontend-elements
website. Then follow these build instructions:
$ cd $ bzip2 -dc libfrontend-elements-1.1.1.tar.bz2 | tar x $ cd libfrontend-elements-1.1.1 $ make Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: y Would you like the C++ compiler to generate debug information? [y]: n Embed dynamic library paths into executables (rpath)? [y]: n Please enter any extra C++ preprocessor options. []: -I ~/STLport-5.0.1/stlport -D_REENTRANT Please enter any extra C++ compiler options. []: -mno-cygwin Please enter any extra C++ linker options. []: -L ~/STLport-5.0.1/lib Please enter any extra C++ libraries. []: -lstlport.5.0 Please select the default library type: (1) archive (2) shared object [2]: 1 Please enter the archiver (ar) binary you would like to use. [ar]: ar Please enter the indexer (ranlib) binary you would like to use. [ranlib]: ranlib Would you like to configure dependency on the installed version of 'libcult' as opposed to the development build? [y]: n Please enter the src_root for 'libcult'. []: ../libcult-1.4.2 Please enter the out_root for 'libcult'. [/home/boris/libcult-1.4.2]: ../libcult-1.4.2 Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Please select the optimization level you would like to use: [2]: 2
Libbackend-elements
Download the latest libbackend-elements source release from
the libbackend-elements
website. Then follow these build instructions:
$ cd $ bzip2 -dc libbackend-elements-1.6.1.tar.bz2 | tar x $ cd libbackend-elements-1.6.1 $ make Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: y Would you like the C++ compiler to generate debug information? [y]: n Embed dynamic library paths into executables (rpath)? [y]: n Please enter any extra C++ preprocessor options. []: -I ~/STLport-5.0.1/stlport -D_REENTRANT Please enter any extra C++ compiler options. []: -mno-cygwin Please enter any extra C++ linker options. []: -L ~/STLport-5.0.1/lib Please enter any extra C++ libraries. []: -lstlport.5.0 Please select the default library type: (1) archive (2) shared object [2]: 1 Please enter the archiver (ar) binary you would like to use. [ar]: ar Please enter the indexer (ranlib) binary you would like to use. [ranlib]: ranlib Would you like to configure dependency on the installed version of 'boost libraries' as opposed to the development build? [y]: n Please enter the 'boost' root directory. []: ../boost_1_33_1 Please select the library type you would like to use: (1) archive (2) shared object [2]: 1 For boost 1.34.0 and later, please enter the toolset version that is embedded into the library names. For example, for gcc34 enter 34. For previous versions of boost leave this field blank. []: Would you like to configure dependency on the installed version of 'libcult' as opposed to the development build? [y]: n Please enter the src_root for 'libcult'. []: ../libcult-1.4.2 Please enter the out_root for 'libcult'. [/home/boris/libcult-1.4.2]: ../libcult-1.4.2 Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Please select the optimization level you would like to use: [2]: 2
Libxsd-frontend
Download the latest libxsd-frontend source release from the
libxsd-frontend
project page. Then follow these build instructions:
$ cd $ bzip2 -dc libxsd-frontend-1.15.0.tar.bz2 | tar x $ cd libxsd-frontend-1.15.0 $ make Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: y Would you like the C++ compiler to generate debug information? [y]: n Embed dynamic library paths into executables (rpath)? [y]: n Please enter any extra C++ preprocessor options. []: -I ~/STLport-5.0.1/stlport -D_REENTRANT -DXML_LIBRARY Please enter any extra C++ compiler options. []: -mno-cygwin Please enter any extra C++ linker options. []: -L ~/STLport-5.0.1/lib Please enter any extra C++ libraries. []: -lstlport.5.0 Please select the default library type: (1) archive (2) shared object [2]: 1 Please enter the archiver (ar) binary you would like to use. [ar]: ar Please enter the indexer (ranlib) binary you would like to use. [ranlib]: ranlib Would you like to configure dependency on the installed version of 'libfrontend-elements' as opposed to the development build? [y]: n Please enter the src_root for 'libfrontend-elements'. []: ../libfrontend-elements-1.1.1 Please enter the out_root for 'libfrontend-elements'. [/home/boris/libfrontend-elements-1.1.1]: ../libfrontend-elements-1.1.1 Would you like to configure dependency on the installed version of 'libcult' as opposed to the development build? [y]: n Please enter the src_root for 'libcult'. []: ../libcult-1.4.2 Please enter the out_root for 'libcult'. [/home/boris/libcult-1.4.2]: ../libcult-1.4.2 Would you like to configure dependency on the installed version of 'libxerces-c' as opposed to the development build? [y]: n Please enter the 'libxerces-c' root directory. []: ../xerces-c-3.0.0 Please select the library type you would like to use: (1) archive (2) shared object [2]: 1 Would you like to configure dependency on the installed version of 'boost libraries' as opposed to the development build? [y]: n Please enter the 'boost' root directory. []: ../boost_1_33_1 Please select the library type you would like to use: (1) archive (2) shared object [2]: 1 For boost 1.34.0 and later, please enter the toolset version that is embedded into the library names. For example, for gcc34 enter 34. For previous versions of boost leave this field blank. []: Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Please select the optimization level you would like to use: [2]: 2
XSD
Download the latest XSD source release from the XSD project page. Then follow these build instructions:
$ cd $ bzip2 -dc xsd-3.2.0-1.tar.bz2 | tar x $ cd xsd-3.2.0-1/xsd $ make Please select the C++ compiler you would like to use: (1) GNU C++ (g++) (2) Intel C++ (icc) [1]: 1 Would you like the C++ compiler to optimize generated code? [y]: y Would you like the C++ compiler to generate debug information? [y]: n Embed dynamic library paths into executables (rpath)? [y]: n Please enter any extra C++ preprocessor options. []: -I ~/STLport-5.0.1/stlport -D_REENTRANT -DXML_LIBRARY Please enter any extra C++ compiler options. []: -mno-cygwin Please enter any extra C++ linker options. []: -L ~/STLport-5.0.1/lib Please enter any extra C++ libraries. []: -lstlport.5.0 Would you like to configure dependency on the installed version of 'libxsd-frontend' as opposed to the development build? [y]: n Please enter the src_root for 'libxsd-frontend'. []: ../../libxsd-frontend-1.15.0 Please enter the out_root for 'libxsd-frontend'. [/home/boris/libxsd-frontend-1.15.0]: ../../libxsd-frontend-1.15.0 Would you like to configure dependency on the installed version of 'boost libraries' as opposed to the development build? [y]: n Please enter the 'boost' root directory. []: ../../boost_1_33_1 Please select the library type you would like to use: (1) archive (2) shared object [2]: 1 Would you like to configure dependency on the installed version of 'libbackend-elements' as opposed to the development build? [y]: n Please enter the src_root for 'libbackend-elements'. []: ../../libbackend-elements-1.6.1 Please enter the out_root for 'libbackend-elements'. [/home/boris/libbackend-elements-1.6.1]: ../../libbackend-elements-1.6.1 Would you like to configure dependency on the installed version of 'libcult' as opposed to the development build? [y]: n Please enter the src_root for 'libcult'. []: ../../libcult-1.4.2 Please enter the out_root for 'libcult'. [/home/boris/libcult-1.4.2]: ../../libcult-1.4.2 Would you like to build optional parts of 'XSD' that require the 'ACE' library? [n]: n Would you like to build optional parts of 'XSD' that require the 'XDR' library (part of the system in most GNU/Linux and UNIX distributions)? [n]: n Would you like to build optional parts of 'XSD' that require the boost 'serialization' library? [n]: n Would you like to build optional parts of 'XSD' that require the boost 'date_time' library? [n]: n Would you like to build optional parts of 'XSD' that require the 'Berkeley DB XML' library? [n]: n Would you like to build optional parts of 'XSD' that require the XQilla library? [n]: n Please enter the g++ binary you would like to use, for example 'g++-3.4', '/usr/local/bin/g++' or 'distcc g++'. [g++]: g++ Please select the optimization level you would like to use: [2]: 2 $ ./xsd --version XML Schema Definition Compiler 3.2.0
After this step the XSD compiler executable can be found in
the xsd-3.2.0-1/xsd directory. Note that you've
just built a native Win32 executable and as such it expects
Win32 paths. As a result, you cannot use absolute Cygwin
paths (e.g., /tmp/schema.xsd) with this binary.