Installing XSD on Windows

This README describes installing the XSD compiler (xsd) and runtime library (libxsd) from binary packages on Windows. Note that the runtime library is header-only.

Besides the runtime library, the generated code also depends on the underlying XML parser which can be Xerces-C++ for the C++/Tree mapping and Xerces-C++ or Expat for the C++/Parser mapping. You can get these XML parsers from a package manager such as vcpkg. The Xerces-C++ binary package is also provided with the XSD packages.

The following binary packages are provided for Windows (here <...> denotes the version and architecture information):

xsd-<...>-windowsX.zip                       -- XSD compiler
libxsd-<...>-windows.zip                     -- XSD runtime library
libxerces-c-<...>-windowsX-msvcA.B.zip       -- Xerces-C++ library
libxerces-c-<...>-windowsX-msvcA.B-debug.zip -- Xerces-C++ debug library

Note that the XSD compiler package is statically linked and can be used on Windows version X or later. The Xerces-C++ package is built with MSVC version A.B and should be usable with that or later versions (it also normally works with earlier A.* versions).

All the packages are relocatable and can be installed into any location. To install them you can use your favorite zip archive extractor. Alternatively, on recent Windows 10 builds you can use the included BSD tar command line utility. For example, to install to C:\xsd:

> md C:\xsd
> tar -xf xsd-<...>.zip -C C:\xsd --strip-components=1
> tar -xf libxsd-<...>.zip -C C:\xsd --strip-components=1
> tar -xf libxerces-c-<...>.zip -C C:\xsd --strip-components=1

The resulting directory structure in C:\xsd will look as follows:

C:\xsd\
├── bin\
│   ├── xerces-c-3.2.dll      -- Xerces-C++ DLL
│   └── xsd.exe               -- XSD compiler
├── include\
│   ├── xercesc\              -- Xerces-C++ headers
│   └── xsd\                  -- XSD runtime headers
└── lib\
    ├── xerces-c.dll.lib      -- Xerces-C++ import library
    └── xerces-c.lib          -- Xerces-C++ static library

To test the installation you can try to build and run an example, for example cxx/tree/hello/ from the xsd-examples source package (see examples README for details). Start an appropriate (normally x64) Visual Studio Command Prompt and then execute:

> C:\xsd\bin\xsd cxx-tree hello.xsd
> cl /IC:\xsd\include /DLIBXERCES_C_SHARED /EHsc /c hello.cxx
> cl /IC:\xsd\include /DLIBXERCES_C_SHARED /EHsc /c driver.cxx
> link /LIBPATH:C:\xsd\lib driver.obj hello.obj xerces-c.dll.lib

> set "PATH=C:\xsd\bin;%PATH%"
> .\driver.exe hello.xml

To integrate the installation into your build system of IDE, add C:\xsd\bin to the executable search paths (or to the PATH environment variable), C:\xsd\include to the header search paths, and C:\xsd\lib to the library search paths. Then link your application with xerces-c.dll.lib (or xerces-c.lib if you wish to link Xerces-C++ statically).