Friday, June 12, 2015

building libxml2 in visual studio 2013

How to build release & debug x64 static libraries with /MT or /MTd runtime consequently.
Build without dependencies (as I understand here can be somehow optional included icu & zlib libraries).


1) download sources
git clone git://git.gnome.org/libxml2

2) configure and make.
Open visual studio console (if you open x32 console - it builds x32 library, if x64 - it builds x64 library). Go to libxml2/win32 and enter:
cscript.exe configure.js iconv=no compiler=msvc cruntime=/MT  debug=no  prefix="..\_build_x64_static_release_mt" static=yes
nmake Makefile.msvc libxml install
nmake clean
cscript.exe configure.js iconv=no compiler=msvc cruntime=/MTd debug=yes prefix="..\_build_x64_static_debug_mtd"  static=yes
nmake Makefile.msvc libxml install


'debug=yes' means generate unoptimized code and generate debug symbols.
'debug=no' means generate optimized code and not to generate debug symbols.
such 'prefix' values put include/library/binary files into the directory in the root of your libxml2 with good name.

3) If you want to use libxml only as static library - you can define LIBXML_STATIC in it's headers. You need to do it with headers:
  • threads.h
  • xmlexports.h
  • xmlwin32version.h
 In these files you need before first occurrence LIBXML_STATIC insert something like
#ifndef LIBXML_STATIC
#define LIBXML_STATIC
#endif

1 comment: