Thursday, January 24, 2013

XML_C14N error when compiling libxmlsec


OK, as an bioinformatician I always work with compiling and running with many different tools. Here comes with the problem: I need to install the genefilter package in R, which is a great package for performing microarray analysis. In our institute cluster, it works well in the head node but not in other nodes. Further inspection shows that a static library, libxmlsec, is missing in these nodes. Compiling this library is painful as you have to deal with many different errors...

After a few days of struggle, I successfully compiled libxmlsec and now genefilter works fine for all nodes in the cluster. Here I just write down some error messages and my solutions, in cases others have the same problem.

XMLSEC compiling errors: XML_C14N_1_0 undeclared

The error message is something like:

c14n.c: In function 'xmlSecTransformC14NExecute':
c14n.c:423: error: 'XML_C14N_1_0' undeclared (first use in this function)
c14n.c:423: error: (Each undeclared identifier is reported only once
c14n.c:423: error: for each function it appears in.)
c14n.c:431: error: 'XML_C14N_1_1' undeclared (first use in this function)
c14n.c:439: error: 'XML_C14N_EXCLUSIVE_1_0' undeclared (first use in this function)

Solution:

XML_C14N_1_0 is defined in libxml2 header files, so check whether your libxml2 has some problems. More specifically, XML_C14N_1_0 is defined in "c14n.h", and older libxml2 headers this is not defined. For me this error occurs since I have an older version of libxml2 in the system, which the compiler overrides a newer version in my home directory. Here is the following command the MAKE used when error occurs:

gcc -DHAVE_CONFIG_H -I. -I.. -DPACKAGE=\"xmlsec1\" -I../include -I../include -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_XKMS=1 -DXMLSEC_DL_LIBLTDL=1, -I/usr/include/libxml2 -I/home/include/libxml2 -g -O2 -MT c14n.lo -MD -MP -MF .deps/c14n.Tpo -c c14n.c  -fPIC -DPIC -o .libs/c14n.o

Look at the include option (-I) in the above example: the system libxml2 headers are in front of my own libxml2 headers, so the system libxml2 headers (which are the older ones) are used instead of the newer libxml2 headers. My solution is to add a symbolic link in the "include" directory of libxml2 pointing to the new libxml2 headers in my home directory:

wl948@header:~/prog/libxmlsec/xmlsec1-1.2.18/include$ ln -s $HOME/include/libxml2/libxml libxml

which solve this issue because right now the newer libxml2 headers are in front of the system libxml2 files.

I'm sure there should be alternative solutions in the configure program by providing a proper option (probably by setting some environment variables) but I didn't check. Anyone has any ideas?