Hugin SDK (MSVC 2013)

From Wiki
Revision as of 20:33, 19 May 2015 by Thomas (talk | contribs) (exiv2)
Jump to: navigation, search

This side contains some notes to compile Hugin with MS Visual Studio Community Edition 2013.

This instructions applies to build all libs as shared libraries (aka dll). All instructions refers to 32 and 64 bit except otherwise noted.


First install the following prerequisites:

  • Visual Studio 2013 Community Edition: [1] (Please don't use the 2015 version. Not all needed libraries are updated for the new compiler generation.)
  • CMake [2] (select win32 installer )
  • Tortoise HG, to get code from repository [3] (select 32 or 64 bit, which one is appropriate for your system, not for the architecture you are building)
  • MS HTML Help Workshop, for creating the help file [4]
  • 7-zip, to extract some downloads [5]


General notes

  • First create a directory, where we build all libraries and program. This directory is called SDKROOT in the following steps. It's best to use a directory without white spaces or other special characters, e.g. c:\huginSDK would be a good point. Replace SDKROOT with your real path in all places.
  • There are mainly 2 build ways, depending on the library
    • The CMake way
    • The nmake way

In the following we will give only short instructions, and mention where differences to the general way are.

The CMake way

  1. Open the CMake (CMake-gui) from the start menu
  2. Browse to the path where you extracted the source
  3. Specify a path where the library is build. Normally use SDKROOT\build_lib (Replace lib with the name of the corresponding library.)
  4. Now select Configure, confirm directory creation, select Visual Studio 12 2013 for building 32 bit version or Visual Studio 12 2013 Win64 for the 64 bit version
  5. Tick option Advanced and Grouped to see all possible variables.
  6. When configure finished with error, edit some variables as described in the individual section. (If the variables does not exists after configure, create it Add entry.) Then press configure again.
  7. Repeat until CMake reports Configuring done and there are no red keys in the GUI.
  8. Now select Generate
  9. Open the generated project file (xxx.sln) in the build folder
  10. In Visual Studio check that on the top there is selected Release and Win32 (for 32 bit Hugin) or x64 (for 64 bit Hugin).
  11. Select the project INSTALL, open context menu (right menu button) and select Build
  12. Now VS builds the lib and copies all necessary files to the install destination.

The nmake way

  1. Open Start>Visual Studio 2013>Visual Studio Tools
  2. Start VS2013 x86 Native Tools Command Prompt (for 32 bit) or VS2013 x64 Native Tools Command Prompt (for 64 bit)
  3. Switch to the path where you extracted the source
   cd SDKROOT\lib
  1. Now build the library. The exact instructions are given in the approbate section.


  • Download from [6] (.7z version is fine)
  • Extract to SDKROOT\boost_1_58_0
  • Now via the nmake way
    cd SDKROOT\boost_1_58_0
  • Now build for 32 bit with
    b2 --with-system --with-filesystem toolset=msvc variant=debug variant=release link=shared threading=multi runtime-link=shared stage

or for 64 bit

    b2 --with-system --with-filesystem toolset=msvc variant=debug variant=release link=shared threading=multi runtime-link=shared address-model=64 stage


  • Download from [7] Windows Source and extract source to SDKROOT\wxWidgets-3.0.2
  • Also via the nmake way
    cd SDKROOT\wxWidgets-3.0.2\build\msw
  • Now build for 32 bit
    nmake -f BUILD=debug SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic
    nmake -f BUILD=release SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic

or for 64 bit

    nmake -f BUILD=release TARGET_CPU=AMD64 SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic


  • Download zlib 1.2.8 from [8] and extract source to SDKROOT\zlib-1.2.8
  • Now via the CMake way
  • After configure change key
  • Now configure, generate, open project file and build INSTALL project (as described on top).


  • Download libpng from [9] (e.g. zip version) and extract source
  • Also via CMake
  • Change the following keys:
   PNG_SHARED [x] (selected)
   PNG_STATIC [ ] (not selected)
   ZLIB_INCLUDE_DIR = SDKROOT\zlib\include
   ZLIB_LIBRARY = SDKROOT\zlib\lib\zlib.lib
  • Finish CMake steps.


  • Download libjpeg from [10] and extract source.
  • Open file in notepad and change the line
   # Pull in standard variable definitions
   !include <win32.mak>


   # Pull in standard variable definitions
   #include <win32.mak>

and save. Now open file jmorecfg.h and change the lines

   /* a function referenced thru EXTERNs: */
   #define GLOBAL(type)		type
   /* a reference to a GLOBAL function: */
   #define EXTERN(type)		extern type


   /* a function referenced thru EXTERNs: */
   #define GLOBAL(type)		__declspec(dllexport) type
   /* a reference to a GLOBAL function: */
   #define EXTERN(type)		extern __declspec(dllexport) type

and save again.

  • Now open a Visual studio command prompt (as in the nmake way) and
   cd SDKROOT\jpeg-9a
   nmake /f setup-v10
  • Now open project file jpeg.sln in SDKROOT\jpeg-9a and confirm update of project files.
  • For 64 bit only: Open combo box with Win32 and select Configuration Manager. Under active platform select New.. and choose then new Platform x64 and copy from Win32. (When build 32 bit version, this is not necessary.)
  • Open context menu on jpeg project, select Properties. Under Properties, Configuration type switch from Static lib (.lib) to Dynamic lib (.dll). Close dialog.
  • Open context menu on jpeg project again, now select Build.


  • Download libtiff from [11] and extract source.
  • Edit file nmake.opt in notepad. Change the lines
       # Uncomment and edit following lines to enable JPEG support.
       #JPEG_SUPPORT   = 1
       #JPEGDIR        = d:/projects/jpeg-6b
       #JPEG_LIB       = $(JPEGDIR)/Release/jpeg.lib
       # Uncomment and edit following lines to enable ZIP support
       # (required for Deflate compression and Pixar log-format)
       #ZIP_SUPPORT    = 1
       #ZLIBDIR        = d:/projects/zlib-1.2.1
       #ZLIB_LIB       = $(ZLIBDIR)/zlib.lib


       # Uncomment and edit following lines to enable JPEG support.
       JPEG_SUPPORT	= 1
       JPEGDIR 	= SDKROOT/jpeg-9a
       JPEG_LIB        = $(JPEGDIR)/Release/jpeg.lib  # for 32 bit
       JPEG_LIB        = $(JPEGDIR)/x64/Release/jpeg.lib  # for 64 bit
       # Uncomment and edit following lines to enable ZIP support
       # (required for Deflate compression and Pixar log-format)
       ZIP_SUPPORT	= 1
       ZLIBDIR 	= SDKROOT/zlib/include
       ZLIB_LIB 	= SDKROOT/zlib/lib/zlib.lib

Keep in mind to replace SDKROOT with your full path (use normal slash / instead of backslash \). Also for JPEG_LIB leave only one entry (depending on architecture). Save.

  • Now via the nmake way:
     cd SDKROOT\libtiff-4.0.3


  • Download IlmBase from [12] and extract source.
  • Via the CMake way, change the following keys
  BUILD_SHARED_LIBS [x] (selected)
  • Finish CMake steps.


  • Download OpenEXR from [13] and extract file.
  • Via the CMake way, change the following keys
   ZLIB_INCLUDE_DIR = SDKROOT\zlib\include
   ZLIB_LIBRARY = SDKROOT\zlib\lib\zlib.lib
  • Open the project file and select build from the context menu of the IlmImf project. This will fail with an error message. Now copy all dll files from SDKROOT\Deploy\lib to build-OpenEXR\IlmImf\Release. Now try to build IlmImf again. Then build the INSTALL project.


  • Download vigra from [14] and extract source
  • Via the CMake way. Set the following keys
    WITH_HDF5        [ ]
    WITH_OPENEXR     [x]
    WITH_VALGRIND    [ ]

and set the following paths (you need to do it sequential, otherwise not all are displayed by default

    ZLIB_INCLUDE_DIR = SDKROOT\zlib\include
    ZLIB_LIBRARY = SDKROOT\zlib\lib\zlib.lib

Press configure again. And now the second part

    JPEG_LIBRARY = SDKROOT\jpeg-9a\Release\jpeg.lib (32 bit)
    JPEG_LIBRARY = SDKROOT\jpeg-9a\x64\Release\jpeg.lib (64 bit)
    PNG_PNG_INCLUDE_DIR = SDKROOT\libpng\include
    PNG_LIBRARY_RELEASE = SDKROOT\libpng\lib\libpng16.lib
    TIFF_INCLUDE_DIR = SDKROOT\tiff-4.0.3\libtiff
    TIFF_LIBRARY = SDKROOT\tiff-4.0.3\libtiff\libtiff_i.lib

and for all OpenExr libraries (Half, IEx, IlmImf, Ilmthread, Imath) do the same (replace ? with the real names, some lib can contain an additional version number like -2_2)

    OPENEXR_?_LIBRARY = SDKROOT\Deploy\lib\?.lib
  • Configure, Generate, open project file and build INSTALL project.


  • Load expat 2.1.0 source from [15] and extract.
  • The expat library is build with the exiv2 library. So no additional steps are needed.


  • Download exiv2 source package from [16] and extract.
  • Open project file SDK\exiv-0.24\msvc2012\exiv2.sln and confirm upgrade.
  • Switch to ReleaseDLL and Win32 or x64.
  • Delete zlib1 project (from the context menu). We have already build the zlib library and are using our compiled version.
  • Open context menu on exiv2lib, select properties, go to Configuration properties. Under C/C++ > General > Additional Include directories change (drop down the box and select edit)



Under Linker > Input > Additional dependencies change




And a last change under Build event > Prebuild event > Command Line remove the last part copy/y "$(SolutionDir)zlib\$(Platform)\$(Configuration)\*.dll" "$(OutDir)"

  • Then build the exiv2lib.






  • Download the sqlite-amalgamation and sqlite-dll-win32 from [17] and extract both files to SDKROOT>\sqlite3
  • Via the nmake way. For 32 bit version use
    cl /D_USRDLL /D_WINDLL /MD /D_MBCS /DSQLITE_ENABLE_COLUMN_METADATA /D"SQLITE_API=extern __declspec(dllexport)" sqlite3.c /link /DLL /OUT:sqlite3.dll 
    lib /def:sqlite3.def

or for the 64 bit version

    cl /D_USRDLL /D_WINDLL /MD /D_MBCS /DSQLITE_ENABLE_COLUMN_METADATA /D"SQLITE_API=extern __declspec(dllexport)" sqlite3.c /link /DLL /OUT:sqlite3.dll 
    lib /def:sqlite3.def /machine:x64



  • Download exiftool [18] (select Windows Executable)
  • Create the directory SDKROOT\exiftool
  • Decompress the file to this folder and rename exiftool(-k).exe to exiftool.exe



  • Download enblend/enfuse (32 or 64 bit version, should be match with Hugin architecture) from [19] and extract the archive (e.g. SDKROOT\enblend-enfuse-4.1.3-Win32 or SDKROOT\enblend-enfuse-4.1.3-Win64)

Build Hugin