Using XSD with Qt Creator

From Code Synthesis Wiki

Revision as of 20:28, 5 May 2010; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

Qt Creator for Windows

Qt Creator for Windows uses the MinGW port of GCC as the C++ compiler. MinGW toolchain is installed with the Qt Creator. The first step in using XSD with Qt Creator is to build the Xerces-C++ library with the same C++ compiler as used by Qt Creator. To do this follow these steps:

1. Install a basic Cygwin environment. You only need basic tools such as bash, sed, awk, and make. In particular, you don't need to install gcc since we will be using the one provided with Qt Creator. Instead of Cygwin you can try to use MSYS though it seems that Cygwin is much easier to install.

2. Start the Cygwin shell and set the PATH variable to include the MinGW bin directory that comes with Qt Creator:

$ export PATH=/cygdrive/c/Qt/QtCreator-x.y.z/mingw/bin:$PATH

3. Unpack the latest release of Xerces-C++ and configure and build it like this (we disable building the shared library since Qt Creator's MinGW only includes static libraries):

$ ./configure --host=i686-mingw32msvc --enable-transcoder-windows --enable-netaccessor-winsock --disable-shared CXXFLAGS=-O2 CFLAGS=-O2
$ cd src
$ make

4. Once the build completes, the headers are in src/ and the library is in src/.libs/. You can also install the library and the headers by using the --prefix configure option and the make install target.

5. To test that everything works as expected, you can try to build the XSD examples without using Qt Creator. To do this unpack the XSD Windows distribution and do:

$ cd xsd-x.y.x-windows-i686/examples
$ make CPPFLAGS=-Ic:/path/to/xerces-c-x.y.z/src LDFLAGS=-Lc:/path/to/xerces-c-x.y.z/src/.libs

After you have built the Xerces-C++ library you can build code generated by XSD from Qt Creator. For this to work, you will need to add the following include search paths to your project:

c:/path/to/xerces-c-x.y.z/src
c:/path/to/xsd-x.y.x-windows-i686/libxsd

e.g. .pro file lines (order is important here!!):

INCLUDEPATH += "C:\Program Files\CodeSynthesis XSD 3.3\xerces-c-3.1.1\src" \
               "C:\Program Files\CodeSynthesis XSD 3.3\include"

And the following library search path, and you will also need to link to the Xerces-C++ library:

c:/path/to/xerces-c-x.y.z/src/.libs

e.g. .pro file lines:

LIBS += -L"C:\Program Files\CodeSynthesis XSD 3.3\xerces-c-3.1.1\src\.libs" \
        -lxerces-c
Personal tools