Monday, July 6, 2015

building libxml++ by visual studio

Problem

I want to parse html as DOM - by xpath. The only adequate description found here - http://blog.laplante.io/2014/11/parsing-html-c-revisited/, and it looks like libxml++ the only variant. But here are one huge problem - I'm developing in Visual Studio on Windows, and I prefer static libraries with static runtime. So, I was forced to build all dependencies.
I've found some blog - gtkmm-installation.blogspot.com - well, actuiall I've found it's github project - cloned it, tried to understand what the fuck is going on in this project - didn't understand how does it work and built everything by myself. Maybe if I've read these articles on blogspot I was able to understand it's github content, but somewhy I din't do it. Maybe in the future) Anyway, it's great experience & practice.
Every dependency building I've moved to special blog note, and this one if the final one about libxml++ building.

 

Foreword

I've made graph of dependencies with https://www.draw.io.






Tools & versions

  • visual studio 2013
  • git client
  • Compiled in visual studio 2013 libraries:
    • Compiled intl (version 20090911) in Visual Studio 2013 - [link]
    • Compiled pcre (version 8.37) in Visual Studio 2013 - [link]
    • Compiled libffi (version 3.2.1) in Visual Studio 2013 - [link]
    • Compiled zlib (version 1.2.8) in Visual Studio 2013 - [link]
    • Compiled libsig++ (version 2.4.1) in Visual Studio 2013 - [link]
    • Compiled glib (version 2.45.3) in Visual Studio 2013 - [link]
    • Compiled glibmm (version 2.45.3) in Visual Studio 2013 - [link]
    • Compiled libxml (version 2.9.2) in Visual Studio 2013 - [link]

 

Preparing and checking

---------------------------------------------------------
1) Build libxml2 (I think it's version 2.9.2)
   
    Date:            (03.07.2015 15:58:33)
    Commit hash:    73b2d73df8981e37a03dfdcf727d8bdafb019266
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/building-libxml2-without-dependencies.html
   
    let's assume you have directories:
        D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_release_mt
        D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_debug_mtd
       
---------------------------------------------------------
2) Build zlib (version 1.2.8)
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/note-of-mt-x64-static-zlib-compiling.html
   
    let's assume you have -MT here:
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_release_mt\include\zlib.h
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_debug_mtd\include\zconf.h
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_release_mt\lib\zlib.lib
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_release_mt\lib\zlib.pdb
    and -MTd here:
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_debug_mtd\include\zlib.h
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_debug_mtd\include\zconf.h
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_debug_mtd\lib\zlib.lib
        D:\projects\libraries\libxmlplusplus\zlib-1.2.8\_build_x64_static_debug_mtd\lib\zlib.pdb
   
---------------------------------------------------------
3) Build intl (version 20090911)
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/proxy-libintl-note.html
   
    let's assume you have -MT here:
        D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_release_mt\include\libintl.h
        D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_release_mt\lib\intl.lib
    and -MTd here:
        D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_debug_mtd\include\libintl.h
        D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_debug_mtd\lib\intl.lib
       
---------------------------------------------------------
4) Build libffi (version 3.2.1)
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/building-libffi-on-windows-by-visual.html
   
    let's assume you have -MT here:
        D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_release_mt\include
        D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_release_mt\.libs\libffi_convenience.lib
    and -MTd here:
        D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_debug_mtd\include
        D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_debug_mtd\.libs\libffi_convenience.lib
       
---------------------------------------------------------
5) Build pcre (version 8.37)
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/07/building-pcre-on-visual-studio.html
   
    let's assume you have -MT here:
        D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_release_mt\include\pcre.h
        D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_release_mt\Release\pcre.lib
    and -MTd here:
        D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_debug_mtd\include\pcre.h
        D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_debug_mtd\Debug\pcred.lib
       
---------------------------------------------------------
6) libsigc++ (version 2.4.1)
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/build-sigc-in-visual-studio.html
   
    let's assume you have -MT here:
        D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\MSVC_Net2010\x64\Release\sigc-vc100-2_0.lib
    and -MTd here:
        D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\MSVC_Net2010\x64\Debug\sigc-vc100-d-2_0.lib
       
---------------------------------------------------------
7) glib (I think it's version 2.45.3)
   
    Date:            (02.07.2015 14:06:17)
    Commit hash:    e337fe31637fe868ab94b488caf9b4898a2a1040
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/06/build-minimal-glib-in-visual-studio.html
   
    lets assume you have projects here:
        D:\projects\libraries\libxmlplusplus\glib
    and binaries -MT here (despite we built Release_ExtPCRE, binaries will be in Release directory):
        D:\projects\libraries\libxmlplusplus\glib\build\win32\vs10\Release\x64\bin
    and binaries -MTd here (despite we built Debug_ExtPCRE, binaries will be in Debug directory):
        D:\projects\libraries\libxmlplusplus\glib\build\win32\vs10\Debug\x64\bin
   
---------------------------------------------------------   
8) glibmm (2.45.3)

    Date:            (02.07.2015 22:03:00)
    Commit hash:    9c5e30622e38974e909fef60ea045d08000e33a0
   
    You can use this tutorial:
        http://hostagebrain.blogspot.com/2015/07/building-glibmm-by-visual-studio.html
       
    lets assume you have projects here:
        D:\projects\libraries\libxmlplusplus\glibmm
    and binaries -MT here
        D:\projects\libraries\libxmlplusplus\glibmm\MSVC_Net2010\Release\x64\bin
    and binaries -MTd here
        D:\projects\libraries\libxmlplusplus\glibmm\MSVC_Net2010\Debug\x64\bin
   
---------------------------------------------------------

Action

As always, I assume building is going on in directory 'D:\projects\libraries\libxmlplusplus' and all dependencies built by my instructions.

1) Take sources from http://ftp.gnome.org/pub/GNOME/sources/libxml++/

2) Open 'D:\projects\libraries\libxmlplusplus\libxml++-2.38.1\MSVC_Net2010\libxml++.sln'

3) Here are several files must be added in libxml++ project:
  • libxml++\validators\relaxngvalidator.cc
  • libxml++\validators\relaxngvalidator.h
  • libxml++\validators\schemavalidatorbase.cc
  • libxml++\validators\schemavalidatorbase.h
  • libxml++\validators\xsdvalidator.cc
  • libxml++\validators\xsdvalidator.h
  • libxml++\nodes\entitydeclaration.cc
  • libxml++\nodes\xincludeend.cc
  • libxml++\nodes\xincludestart.cc
  • libxml++\nodes\entitydeclaration.h
  • libxml++\nodes\xincludeend.h
  • libxml++\nodes\xincludestart.h
  • libxml++\attributedeclaration.cc
  • libxml++\attributenode.cc
  • libxml++\relaxngschema.cc
  • libxml++\schemabase.cc
  • libxml++\xsdschema.cc
  • libxml++\attributedeclaration.h
  • libxml++\attributenode.h
  • libxml++\relaxngschema.h
  • libxml++\schemabase.h
  • libxml++\xsdschema.h
  • libxml++\schema.cc
  • libxml++\schema.h
4) make libxml++ project static library

5) set /MT or /MTd to libxml++ project

6) make two property sheets - for 'Release x64' and for 'Debug x64'

Debug x64:
  • additional include directories
    • D:\projects\libraries\libxmlplusplus\glib
    • D:\projects\libraries\libxmlplusplus\glib\glib
    • D:\projects\libraries\libxmlplusplus\glibmm\glib
    • D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_debug_mtd\include\libxml2
    • D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\_cygwin\include\sigc++-2.0
    • D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_debug_mtd\include
    • D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_debug_mtd\include
    • D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_debug_mtd\include
  • additional library directories
    • D:\projects\libraries\libxmlplusplus\glibmm\MSVC_Net2010\Debug\x64\bin
    • D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_debug_mtd\lib
    • D:\projects\libraries\libxmlplusplus\glib\build\win32\vs10\Debug\x64\bin
    • D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_debug_mtd\.libs
    • D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\MSVC_Net2010\x64\Debug
    • D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_debug_mtd\Debug
    • D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_debug_mtd\lib
  • input
    • glibmm.lib
    • libxml2_a.lib
    • glib.lib
    • gobject.lib
    • sigc-vc100-d-2_0.lib
    • ws2_32.lib
    • pcred.lib
    • winmm.lib
    • libffi_convenience.lib
    • intl.lib
Release x64:
  • additional include directories
    • D:\projects\libraries\libxmlplusplus\glib
    • D:\projects\libraries\libxmlplusplus\glib\glib
    • D:\projects\libraries\libxmlplusplus\glibmm\glib
    • D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_release_mt\include\libxml2
    • D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\_cygwin\include\sigc++-2.0
    • D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_release_mt\include
    • D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_release_mt\include
    • D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_release_mt\include
  • additional library directories
    • D:\projects\libraries\libxmlplusplus\glibmm\MSVC_Net2010\Release\x64\bin
    • D:\projects\libraries\libxmlplusplus\libxml2\_build_x64_static_release_mt\lib
    • D:\projects\libraries\libxmlplusplus\glib\build\win32\vs10\Release\x64\bin
    • D:\projects\libraries\libxmlplusplus\libffi-3.2.1\_build_x64_static_release_mt\.libs
    • D:\projects\libraries\libxmlplusplus\libsigc++-2.4.1\MSVC_Net2010\x64\Release
    • D:\projects\libraries\libxmlplusplus\pcre-8.37\_build_x64_static_release_mt\Release
    • D:\projects\libraries\libxmlplusplus\intl\_build_x64_static_release_mt\lib
  • input
    • glibmm.lib
    • libxml2_a.lib
    • glib.lib
    • gobject.lib
    • sigc-vc100-2_0.lib
    • ws2_32.lib
    • pcre.lib
    • winmm.lib
    • libffi_convenience.lib
    • intl.lib
It must be exactly libxml2_a.lib, not libxml2.lib, becase 'libxml2.lib' makes dynamic linking.

7) Add property sheet to every project in solution.

8) Select all 'examples...' projects, go to their properties, and make two things:
  • delete .lib filename from 'input'
  • set runtime library - /MT or /MTd

9) To projects:
  • examples_dom_parse_entities
  • examples_dom_parser
add file 'testutilities.cc' to the project (it's located here: 'libxml++-2.38.1\examples\testutilities.cc').

8) Build all - everything must compiles successfully!

Run any example* .exe file - if everything is ok, it must just print something in console and correctly finishes.

1 comment: