XML Security Library

LibXML2
LibXSLT
OpenSSL

Building the application with XML Security Library.

As usual, compiling and linking application with XML Security Library requires specifing correct compilation flags, library files and paths to include and library files.


Include files

In order to use XML Security Library an application should include one or more of the following files:

  • xmlsec/xmlsec.h - XML Security Library initialization and shutdown functions;

  • xmlsec/xmldsig.h - XML Digital Signature functions;

  • xmlsec/xmlenc.h - XML Encryption functions;

  • xmlsec/xmltree.h - helper functions for XML documents manipulation;

  • xmlsec/templates.h - helper functions for dynamic XML Digital Signature and XML Encryption templates creation;

  • xmlsec/crypto.h - automatic XML Security Crypto Library selection.

If necessary, the application should also include LibXML, LibXSLT and crypto library header files.

Example 1. Example includes file section.

#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>

#ifndef XMLSEC_NO_XSLT
#include <libxslt/xslt.h>
#endif /* XMLSEC_NO_XSLT */

#include <xmlsec/xmlsec.h>
#include <xmlsec/xmltree.h>
#include <xmlsec/xmldsig.h>
#include <xmlsec/xmlenc.h>
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
	    

Compiling and linking on Unix.

On Unix-like systems the xmlsec1-config script is the simplest way to get all necessary information.

Example 2. Using xmlsec1-config script in a Makefile.

PROGRAM	 	 = test
PROGRAM_FILES	 = test.c
cc	 	 = gcc
CC	 	 = gcc
LD	 	 = gcc

CFLAGS		+= -g $(shell xmlsec1-config --cflags)
LDFLAGS		+= -g
LIBS 		+= $(shell xmlsec1-config --libs) 

all: $(PROGRAM)

%: %.c 
	$(cc) $(PROGRAM_FILES) $(CFLAGS) $(LDFLAGS) -o $(PROGRAM) $(LIBS)

clean:
	@rm -rf $(PROGRAM)
	    

Compiling and linking on Windows.

On Windows there is no such simple and elegant solution. Please check README file in win32 folder of the library package for latest instructions. However, there are a couple general things, that you need to remember:

  • All libraries linked to your application must be compiled with the same Microsoft Runtime Libraries.

  • Static linking with XML Security Library requires additional global defines:

    #define LIBXML_STATIC
    #define LIBXSLT_STATIC
    #define XMLSEC_STATIC	    
    	     


Compiling and linking on other systems.

Well, nothing is impossible, it's only software (you managed to compile the library itself, do you?). I'll be happy to include in this manual your expirience with compiling and linking applications with XML Security Library on other platforms (if you would like to share it).



Aleksey Sanin