C++ Based OPC UA Client/Server/PubSub SDK  1.7.6.537
Compiling LibXml2 for Windows CE

The following sections describe how to compile LibXml2 from source for Windows CE with Visual Studio 2008.

Requirements

You will need tar to unpack the LibXml2 source package. Download and install Cygwin from https://cygwin.com/install.html. The default installation includes tar.

A Windows CE SDK is required to build LibXml2 for Windows CE. The following example uses our Windows CE SDK, you’ll have to make some adjustments regarding your own toolchain.

Debug and Release

The actions described in the following steps may differ depending on the libraries to be compiled for debug or release mode. This will be noted in each step below if applicable.

Furthermore, it is described how to append a “d” to the filename for debug mode if you inted to use debug and release libraries side by side.

Download and Unpack LibXml2

Download the most recent version of LibXml2 from http://xmlsoft.org/downloads.html. Start a cygwin terminal, navigate to the folder containing the downloaded archive and unpack it:

tar –xvzf libxml2-<version>.tar.gz

Create a Visual Studio Solution

Open Visual Studio and create a new Win32 project called libxml2. Choose “Dll” as application type and “Empty project” at “Additional options”. it to the unpacked folder libxml2-<version>. Choose BuildConfiguration Manager from the menu and pick your Windows CE platform from the menu. For our example, we want to build for Windows CE 7 on x86 using our Windows CE SDK, so we’re picking Unified_Automaiton_WCE_700 (x86).

We need to add the following source files located in the <libxml2 directory> to the solution:

  • buf.c
  • c14n.c
  • catalog.c
  • chvalid.c
  • debugXML.c
  • dict.c
  • DOCBparser.c
  • encoding.c
  • entities.c
  • error.c
  • globals.c
  • hash.c
  • HTMLparser.c
  • HTMLtree.c
  • legacy.c
  • list.c
  • nanoftp.c
  • nanohttp.c
  • parser.c
  • parserInternals.c
  • pattern.c
  • relaxng.c
  • SAX.c
  • SAX2.c
  • schematron.c
  • threads.c
  • tree.c
  • uri.c
  • valid.c
  • xinclude.c
  • xlink.c
  • xmlIO.c
  • xmlmemory.c
  • xmlmodule.c
  • xmlreader.c
  • xmlregexp.c
  • xmlsave.c
  • xmlschemas.c
  • xmlschemastypes.c
  • xmlstring.c
  • xmlunicode.c
  • xmlwriter.c
  • xpath.c
  • xpointer.c

Furthermore, we need to add <libxml2 directory>\win32\wince\wincecompat.c.

We have to set the following preprocessor defines:

_WIN32_WCE=$(CEVER)
UNDER_CE
WINCE
$(ARCHFAM)
$(_ARCHFAM_)
_CRT_SECURE_NO_DEPRECATE
_CRT_NONSTDC_NO_DEPRECATE
_WINDOWS
_USRDLL
CEDLL_EXPORTS
NO_SYS_TYPES_H
HAVE_STDLIB_H
_WINSOCKAPI_
_DEBUG (leave this one out in release mode)

We need the following include directories:
<libxml2 directory>
<libxml2 directory>\win32\wince
<libxml2 directory>\include
<libxml2 directory>\include\libxml

Finally, we have to adjust some linker settings.

  • At Additional Dependencies, add ws2.lib.
  • Add the following command line option: /entry:"_DllMainCRTStartup"
  • To add a “d” at the end of the filename in debug mode, change “Output File” to “$(OutDir)\$(ProjectName)d.dll”

Disable iconv

To disable the patent-registered algorithm iconv, we have to edit the file <libxml2 directory>\include\libxml\xmlversion.h:

/*
* LIBXML_ICONV_ENABLED:
* Whether iconv support is available
*/
#if 1
#undef LIBXML_ICONV_ENABLED
#endif

Now we are ready to compile the libraries.

Copy the Libraries to the SDK Folder Structure

Finally, it is necessary to copy the library files to the SDK folder structure. Create a folder named
<SDK Installation Directory>\third-party\wince<6/7>\vs<version>\libxml2

A similarly named folder, containing the precompiled LibXml2 binaries shipped with the SDK, should already exist below third-party.

  • Copy the complete include directory to the newly created folder.
  • Create a folder named out32_<ARMV4I/x86> and place the following files inside it:
    libxml2.dll
    libxml2.lib;
  • Create another folder named out32_<ARMV4I/x86>.dbg and place the following files inside it:
    libxml2d.dll
    libxml2d.lib
    libxml2d.pdb.