XmlBlaster Logo



XmlBlaster Logo

Type NEW
Priority HIGH
Topic In order to build and run c++ clients, several preconditions need to be fulfilled.

The impatient Unix user may directly jump to the compilation example, others should read the next paragraphs to save time.


You can use the ant tool with the C++ compile extension cpptasks to compile the xmlBlaster client C++ library, the C++ demo clients and the C++ testsuite. All necessary compile tools are provide in the xmlBlaster distribution.

Tested compilers are gcc/g++ 3.x and 4.x, Intels ICC, MS-Visual C++ 2003 and 2005 and SUN-OS CC. Others standard conforming compilers should work without major effort.

The rules to compile C++ code with ant are in the file xmlBlaster/build.xml which loads your configuration settings (like the installation path of your CORBA library or XML parser) from build.properties. See the configuration example below how to set up build.properties.

The cpptasks support many compilers on many platforms (like OS 390/400, SUN, HP, IBM, g++, Intel icc, borland, VC++), our build.xml is tested currently on Linux and Windows. If you use an exotic platform please check cpptasks if this is supported and extend build.xml to your needs (feedback is welcome).

Cory has added autoconf support but currently this support is outdated and needs reanimation, see xmlBlaster/config/README.autoconf.

You may as well compile the client library with any other compile tool like jam, but currently there is no such support in the xmlBlaster distribution.


To use the C++ client library you need at least the Xerces XML library.

If you want compression support or client side persistent queuing you need additionally the zlib and SQLite

Finally, if you don't want to use our native SOCKET communication protocol you can install a CORBA library as well (MICO, TAO, OMNIORB, ORBACUS and ORBIX are supported)


The C++ threading abstraction library

Note: The omnithread library is included in the xmlBlaster distribution and is automatically compiled with our xmlBlaster/build task. For details how to switch the threading library please read the next paragraphs.

In order to have multi threading support on all different operating systems we can link with the boost C++ multi threading library or with the omniORB - omnithreads multi threading library. Both support many platforms like Linux, Windows, Solaris, AIX, HPUX, MAC etc.

Both libraries have a free license and the necessary code fragments of both are provided in the xmlBlaster distribution, so you don't need to download anything.

The default library used is omnithread but can be switched to boost with an entry in build.properties:


You may want to switch to use omnithreads if you have compilation problems with boost on your OS (like e.g. Solaris).

In the build.properties there are two parameters which tell ant where to find the sources and the includes for the thread library. If you use the default don't make any change. If you use an external boost, then you can point to its thread sources with the variable THREADS_SRC and to the includes with THREADS_INC.

The XML library

You can download the xerces-c library from apache's homepage. Please follow their instructions on how to install/build the xerces library for your platform. The versions tested are 2.6.0 (you need a version > 2.4 because of the used codeset, on this is a problem you can comment out some code snippets to be backward compatible to 1.x).
Now, when building with ant, the xerces-c library will be used. In build.properties make sure that the $xerces.include.dir and $xerces.lib.dir are set correctly (see examples there) and that the link to the directory for xerces is correct.

The CORBA library

If want to use MICO as the corba implementation you can download it from the mico homepage. On how to install and build MICO please follow as usual the instructions given there. Once it is installed, open the file build.properties in the $XMBLASTER_HOME directory. There you must adjust
  • corba.product

to the correct values.


If you want to use TAO please follow the specific TAO requirement

The compression library zlib

Optionally you can link this xmlBlaster C++ client library to the zlib compression library. You need to download zlib yourself at http://www.gzip.org/zlib/. Please choose version 1.2.1 or newer, the older version 1.1.4 does not seem to work properly in stream mode.

The compression rate is impressive, see protocol.socket and client.c.queue

You need to adjust in build.properties following settings:

  • zlib.include.dir is the path to "zlib.h"
  • zlib.lib.dir is on Unix the path to the shared library libz.so and on Windows to zlib.dll and zlib.lib (for compilation)

This settings usually works on a Windows box:

-> Entry in build.properties:

-> Directory listing of C:\zlib (zlib1.lib is a copy of lib\zdll.lib)

As many zlib versions may fly around on your PC you can add a zlib name which contains all references for statical linkage (e.g. zlib.lib on Windows), example:

# On Windows you have to choose the name, usually 'zlib' or 'zlib1' (defaults to 'z' for UNIX):

Example command line settings for Windows

REM Visual C++ 2005 Express Edition Beta 2
REM C and C++

REM ========== Global env settings ======
set JAVA_HOME=C:\PROGRA~1\Java\JDK15~2.0_0
set XMLBLASTER_HOME=C:\xmlBlaster
set CLASSPATH=%XMLBLASTER_HOME%\lib\xmlBlaster.jar

REM ========== C/C++ compilation ========
set PATH=%PATH%;%XMLBLASTER_HOME%\demo\c\socket\bin;%XMLBLASTER_HOME%\demo\c++\bin

REM stdio.h and Winsock2.h (C:\Program Files\Microsoft Platform SDK)

REM uuid.lib (C:\Program Files\Microsoft Platform SDK\Lib)
set lib=%lib%;C:\PROGRA~1\MICROS~2\lib

REM ========== C++ runtime ========
REM C++ only: xerces-c_2_6D.dll (from C:\xerces-c_2_6_0-windows_nt-msvc_60)
set PATH=%PATH%;C:\xerces-c_2_6_0-windows_nt-msvc_60\bin

REM C++ with debug only: MSVCRTD.dll  (where from???)

The compilation step

After adjusting build.properties as described you can compile like this:

  cd xmlBlaster

  build  cpp

Get help with

  build  usage

Supported tasks are
  cpp-lib     --> generates C++ libxmlBlasterClient.sl (shared library .so .sl .dll)
                  Check build.properties settings for C++ CORBA and C++ XML libraries
  cpp-test    --> generates C++ test clients
  cpp-demo    --> generates C++ demo clients
  cpp         --> builds cpp-lib, cpp-test and cpp-demo
  cpp-clean   --> cleans up C++ generated files (object files, corba files etc)
  cpp-delete  --> like 'cpp-clean', but delete shared library and C++ test clients as well

You can later check the shared libraries used like this:
  tasklist /M        (Windows DOS box)
  ldd PublishDemo    (Linux, Solaris)
  otool -L TestMethods (Mac OSX)

Example on Linux SUSE 10.0 64bit

Installing xmlBlaster C++ client library on a SUSE 10.0 32 or 64 bit system is very simple: Just install the delivered g++ 4.0.2, xerces 2.6, SQLLite 2.8.16, zlib 1.2.3 with yast2 from the distribution DVD.

Now configure a $HOME/build.properties

corba.product         = NONE




And compile the xmlBlaster C++ client library:

cd xmlBlaster
./build c cpp

Now you should have shared libraries for C (xmlBlaster/lib/libxmlBlasterClientC.so) and C++ (xmlBlaster/lib/libxmlBlasterClient.so) and a complete set of examples in xmlBlaster/demo/c/socket/bin and xmlBlaster/demo/c++/bin


Example on SunOS 5.11 with CC compiler

Installing xmlBlaster C++ client library on a SunOS 5.11 system is very simple: First install xerces 2.7, SQLLite 2.8.16, zlib 1.2.3

Now configure a $HOME/build.properties

# CC: Sun C++ 5.8 2005/10/13
# build -Duse-CC=true c


CFLAGS=-R /home/xmlblast/xmlBlaster/lib
#c.debug       = false
#cpp.debug     = false





corba.product         = NONE

And compile the xmlBlaster C++ client library:

cd xmlBlaster
./build c cpp

Example with eclipse

If you have installed compiled and installed the dlls, following steps are needed to setup your first own client.

    Properties -> GCC -> Directories:

    Properties -> Linker -> Libraries:

    Properties -> Linker -> Library search path:

    Properties -> Linker -> Miscellaneous -> Linker flags:
      "-Wl,-rpath=${xerces_lib_dir} -Wl,-rpath=${zlib_lib_dir} -Wl,-rpath=${sqlite_lib_dir} -Wl,-rpath=${usr_lib_dir} -Wl,-rpath=${XMLBLASTER_HOME}/lib"

assuming your environment contains:
   export usr_lib_dir=/usr/lib
   export zlib_lib_dir=/opt/zlib-bin/lib
   export sqlite_lib_dir=/opt/sqlite-bin/lib
   export xerces_lib_dir=/opt/xerces-c-src_2_7_0-bin/lib
On Windows you need to set the preprocessor define /D_WINDOWS.

Take a copy from xmlBlaster/build.properties to ${user.home}/build.properties and edit it to find the installation directory of the XERCES lib (and optionally CORBA libs, zlib and sqlite lib).

# Switch debugging of C and C++ client library to true or false
# The debugging shared library name has added a 'D' to its name
#c.debug       = false
#cpp.debug     = false

# Set to 1 if you want to use log4cplus instead of our primitive native logging
# We provide the complete source code with xmlBlaster.
# For configuration hints see http://log4cplus.sourceforge.net

# Enable compression with zlib http://www.gzip.org/zlib/ (1.2.1)
# The older version 1.1.4 does not seem to work properly in stream mode
# You need to download zlib yourself.
#  http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.c.queue.html
#  http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html#compress
# - zlib.include.dir is the path to "zlib.h"
# - zlib.lib.dir is on Unix the path to the shared library libz.so and
#                on Windows to zlib.dll and zlib.lib (for compilation)
# As many zlib versions may fly around on your PC you can add a zlib name
# which contains all references for statical linkage (e.g. zlib.lib on Windows)
# On Windows you have to choose the name, usually 'zlib' or 'zlib1'
# (defaults to 'z' for UNIX):

# Settings of the Xerces-C++ validating XML parser.
# See http://xml.apache.org/xerces-c/ for more details.
# - xerces.include.dir is the path to the xercesc-include directry
#                      (assumes ./xercesc subdirectory);
#                      on Windows the setting could be: C:/xerces-c_2_6_0/src or
#                      C:/xerces-c_2_6_0-windows_nt-msvc_60/include
#                      (defaults to /usr/include)
# - xerces.lib.dir is on Unix the path to the shared library libxerces-c.so and
#                  on Windows to xerces-c_2.lib (for compilation)
#                  (defaults to /usr/lib)
# - xerces.lib.name=xerces-c
#                  on Windows set to xerces-c_2

# Persistent queue support in C or C++ client library with http://www.sqlite.org
# You need to download SQLite yourself, see:
#  http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.c.queue.html
#  http://www.xmlBlaster.org/xmlBlaster/doc/requirements/client.cpp.queue.html
# - sqlite.include.dir is the path to "sqlite.h"
# - sqlite.lib.dir is the path to the shared library (dll) libsqlite.so (libsqlite.dll)

# Compile the SOCKET plugin only, without CORBA.
# See http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.cpp.socket.html
corba.product         = NONE

# More corba examples are in build.properties

Debugging with Purify

If you want to check the C++ client library on your platform with Purify you can try this approach (the example is for Solaris using the CC compiler):

First we rename the CC command to CC.ORIG and replace the CC command by a shell script which inserts purify:


# Purify cannot produce shared objects.
# build -DCPP_LINK=static -verbose cpp > build.log

export PATH


purify CC.ORIG $*

Now we are ready to compile the code with purify:

build -DCPP_LINK=static -DPURIFY=PURIFY -verbose cpp > build.log
Platform        CPP defines (from omniORB)
Windows NT 4.0,2000,XP  __x86__ __NT__ __OSVERSION__=4 __WIN32__
Windows NT 3.5  __x86__ __NT__ __OSVERSION__=3 __WIN32__
Windows 95      __x86__ __WIN32__
Sun Solaris 2.5         __sparc__ __sunos__ __OSVERSION__=5
HPUX 10.x       __hppa__ __hpux__ __OSVERSION__=10
HPUX 11.x       __hppa__ __hpux__ __OSVERSION__=11
IBM AIX 4.x     __aix__ __powerpc__ __OSVERSION__=4
Digital Unix 3.2        __alpha__ __osf1__ __OSVERSION__=3
Linux 2.x (x86)         __x86__ __linux__ __OSVERSION__=2
Linux 2.x (powerpc)     __powerpc__ __linux__ __OSVERSION__=2
OpenVMS 6.x (alpha)     __alpha__ __vms __OSVERSION__=6
OpenVMS 6.x (vax)       __vax__ __vms __OSVERSION__=6
SGI Irix 6.x    __mips__ __irix__ __OSVERSION__=6
Reliant Unix 5.43       __mips__ __SINIX__ __OSVERSION__=5
ATMos 4.0       __arm__ __atmos__ __OSVERSION__=4
NextStep 3.x    __m68k__ __nextstep__ __OSVERSION__=3
Unixware 7      __x86__ __uw7__ __OSVERSION__=5

NOTE: Configuration parameters are specified on command line (-someValue 17) or in the xmlBlaster.properties file (someValue=17). See requirement "util.property" for details.
Columns named Impl tells you if the feature is implemented.
Columns named Hot tells you if the configuration is changeable in hot operation.


Test with other compilers:

   Portland Group C++ Compiler for Linux
   PathScale C++
   Watcom C++ Compiler for Linux
   Green Hills C++ Compiler for Linux
See REQ client.cpp
See REQ client.cpp.logging
See REQ client.cpp.tao
See Xerces XML
See SQLite Database
See ZLib compression

This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.cpp.compile.xml

Back to overview