Hugin SDK (MSVC 2013)

From PanoTools.org Wiki
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.

Prerequisites

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]

Dependencies

General notes

  • First create a directory, where we build all libraries and programs. 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 3 build ways, depending on the library
    • The CMake way
    • The nmake way
    • Visual Studio project files

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.

Boost

  • 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
    bootstrap.bat
  • 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

wxWidgets

  • 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 makefile.vc BUILD=debug SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic
    nmake -f makefile.vc BUILD=release SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic

or for 64 bit

    nmake -f makefile.vc BUILD=debug TARGET_CPU=AMD64 SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic
    nmake -f makefile.vc BUILD=release TARGET_CPU=AMD64 SHARED=1 USE_OPENGL=1 RUNTIME_LIBS=dynamic

zlib

  • 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
   CMAKE_INSTALL_PREFIX = SDKROOT\zlib
  • Now configure, generate, open project file and build INSTALL project (as described on top).

libpng

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

libjpeg

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

to

   # 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

to

   /* 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 makefile.vc 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.

libtiff

  • 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_INCLUDE   = -I$(JPEGDIR)
       #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_INCLUDE   = -I$(ZLIBDIR)
       #ZLIB_LIB       = $(ZLIBDIR)/zlib.lib

to

       #
       # Uncomment and edit following lines to enable JPEG support.
       #
       JPEG_SUPPORT	= 1
       JPEGDIR 	= SDKROOT/jpeg-9a
       JPEG_INCLUDE	= -I$(JPEGDIR)
       # for 32 bit leave
       JPEG_LIB        = $(JPEGDIR)/Release/jpeg.lib
       # *or* for 64 bit leave
       JPEG_LIB        = $(JPEGDIR)/x64/Release/jpeg.lib
       
       #
       # 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_INCLUDE	= -I$(ZLIBDIR)
       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
     nmake Makefile.vc

IlmBase

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

OpenEXR

  • Download OpenEXR from [13] and extract file.
  • Via the CMake way, change the following keys
   BUILD_SHARED_LIB [x] 
   ILMBASE_PACKAGE_PREFIX = SDKROOT\Deploy
   CMAKE_INSTALL_PREFIX = SDKROOT\Deploy
   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.

vigra

  • Download vigra from [14] and extract source
  • Via the CMake way. Set the following keys
    WITH_HDF5        [ ]
    WITH_OPENEXR     [x]
    WITH_VALGRIND    [ ]
    WITH_VIGRANUMPY  [ ]
    CMAKE_INSTALL_PREFIX = SDKROOT\vigra
    CMAKE_CXX_FLAGS =  /DWIN32 /D_WINDOWS /W3 /GR /EHsc /DOPENEXR_DLL

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_INCLUDE_DIR = SDKROOT\jpeg-9a
    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
    OPENEXR_INCLUDE_DIR = SDKROOT\Deploy\include\OpenEXR

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.

expat

  • Load expat 2.1.0 source from [15] and extract.
  • The expat library is build with the exiv2 version 0.24 library. So no additional steps are needed.
  • When using exiv2 0.25 built expat via the CMake way. Change the following entries:
   CMAKE_INSTALL_PREFIX=SDKROOT\expat
  • Finish the CMake steps.

exiv2

  • Download exiv2 source package from [16] and extract.
  • This applies for version 0.25. Build via the CMake way. Change the following keys
  CMAKE_INSTALL_PREFIX = SDKROOT\exiv2
  ZLIB_INCLUDE_DIR = SDKROOT\zlib\include
  ZLIB_LIBRARY = SDKROOT\zlib\lib\zlib.lib
  EXPAT_INCLUDE_DIR = SDKROOT\expat\include
  EXPAT_LIBRARY = SDKROOT\expat\lib\expat.lib

and only the following options should be checked (uncheck all other)

  EXIV2_ENABLE_LENSDATA  [x]
  EXIV2_ENABLE_LIBXMP    [x]
  EXIV2_ENABLE_NLS       [x]
  EXIV2_ENABLE_PNG       [x]
  EXIV2_ENABLE_SHARED    [x]
  EXIV2_ENABLE_XMP       [x]
  • Finish CMake steps.

Old instruction for 0.24

  • Open project file SDK\exiv-0.24\msvc2012\exiv2.sln and confirm upgrade. (Note: The CMake way does not work flawless. So I recommend to use the dedicated project files.)
  • 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, check whether in the (top of the) Properties windows the Configuration is also set to Active(ReleaseDLL), go to Configuration properties. Under C/C++ > General > Additional Include directories change (drop down the box and select edit)
   ../../../zlib-1.2.7 

to

   ../../../zlib/include

Under Linker > Input > Additional dependencies change

   ..\zlib\$(Platform)\$(Configuration)\zlib1.lib

to

   ..\..\..\zlib\lib\zlib.lib

The next change under Build event > Prebuild event > Command Line remove the last part

   copy /y "$(SolutionDir)zlib\$(Platform)\$(Configuration)\*.dll" "$(OutDir)"

And the final change also under Build event > Postbuild event > Command Line remove the last part (2 zlib instances)

   copy/y "$(SolutionDir)zlib\$(Platform)\$(Configuration)\*.dll" "%25X%25"
   copy/y "$(SolutionDir)zlib\$(Platform)\$(Configuration)\*.lib" "%25X%25"

and close dialog with Ok.

  • Then build the exiv2lib project.

freeglut

  • Not needed for Hugin 2015.1 and later.

  • Download freeglut 3.0 from [17] and extract.
  • Build via the CMake way. Change the following entries:
   CMAKE_INSTALL_PREFIX = SDKROOT\glut
   FREEGLUT_BUILD_DEMOS       [ ]
   FREEGLUT_BUILD_SHARED_LIBS [x]
   FREEGLUT_BUILD_STATIC_LIBS [ ]
   FREEGLUT_GLES              [ ]
   FREEGLUT_PRINT_ERRORS      [x]
   FREEGLUT_PRINT_WARNING     [x]
  • Now configure, generate, open project file and build INSTALL project (as described on top).

glew

  • Download GLEW source from [18] and extract to SDKROOT\glew (no version number!)
  • Then open project file glew\build\vc12\glew.sln, select Release and Win32 or x64. Then build glew_shared project.
  • Then move
    • for 32 bit
      • glew32.dll from SDKROOT\glew\bin\Release\Win32 to SDKROOT\glew\bin and
      • glew32.lib from SDKROOT\glew\lib\Release\Win32 to SDKROOT\glew\lib
    • or for 64 bit
      • glew32.dll from SDKROOT\glew\bin\Release\x64 to SDKROOT\glew\bin and
      • glew32.lib from SDKROOT\glew\lib\Release\x64 to SDKROOT\glew\lib

fftw3

  • Download source from [19] and extract.
  • Additional we need from [20] Project files to compile FFTW 3.3 with Visual Studio 2010 under Building FFTW 3.x under Visual C++/Intel compilers (scroll down). Extract this archive into the above folder SDKROOT\fftw-3.3.4.
  • Open project file SDKROOT\fftw-3.3.4\fftw-3.3-libs\fftw-3.3-libs.sln.
  • Select Release and Win32 or x64.
  • Open context menu on libfftw-3.3, select Properties. Under Configuration Properties > General check Platform toolset. Change from Windows 7.1SDK to Visual Studio 2013 (v120). Go to Configuration Properties > C/C++ > Code Generation > Run time library and change to Multi threaded DLL (/MD). Close dialog with Ok.
  • Open context menu on libfftw-3.3, select Add > Existing item, select file SDKROOT\fftw-3.3.4\api\mkprinter-str.c
  • Now build project libfftw-3.3

lcms2

  • Download lcms2 from [21] and extract.
  • Open project file SDKROOT\lcms2-2.7\Projects\VC2013\lcms2.sln, select Release and Win32 or x64.
  • Then build project lcms2_DLL.

sqlite3

  • Download the sqlite-amalgamation and sqlite-dll-win32 from [22] and extract both files to SDKROOT\sqlite3
  • Via the nmake way. For 32 bit version use (really 2 command lines):
    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 (really 2 command lines):

    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

gettext

  • Download gettext Binaries and Dependencies from [23] (The same version can be used for 32 and 64 bit version. We need only the binaries during building of Hugin.)
  • Create the directory SDKROOT\gettext and extract both files to this folder.

exiftool

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

enblend/enfuse

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

Build panotools and Hugin

  • Start TortoiseHG. First we will download the repositories.
  • First for libpano13. Select File > Clone repository and give the paths
   Source:  http://hg.code.sf.net/p/panotools/libpano13/
   Destination:  SDKROOT\libpano-hg
  • And now for Hugin. Again select File > Clone repository and use now
   Source:  http://hg.code.sf.net/p/hugin/hugin
   Destination:  SDKROOT\hugin-hg

This will take some time.

panotools

  • First we need to build panotools. It is a CMake build.
  • So start CMake, give the path to source SDKROOT\libpano-hg and path to build SDKROOT\build-libpano.
  • Important: Before pressing Configure add the following 2 entries:
  Name: BUILD_DLL     Type: BOOL    Value: Checkbox ticked
  Name: HUGIN_BASE_DIR  Type: PATH  Value: SDKROOT\hugin-hg
  • Now press Configure. CMake should find all libraries and finish without error. Now press Generate.
  • Now open project file in SDKROOT\build-libpano, check that on the top there is selected Release and Win32 (for 32 bit Hugin) or x64 (for 64 bit Hugin). Now build the INSTALL project.

Hugin

  • For Hugin we are also using CMake
  • Start CMake, give the path to source SDKROOT\hugin-hg and path to build SDKROOT\build-hugin.
  • Important: Before pressing Configure add the following entry:
  Name: HUGIN_SHARED     Type: BOOL    Value: Checkbox ticked
  • Now press Configure, it will take some time, then it will print an error. Edit the following entry to match your wxWidgets directory suffix
   wxWidget_ROOT_SUFFIX = 3.0.2
  • Press Configure again, after the next error set the Boost suffix analogous
   Boost_root_suffix = _1_58_0
  • Configure again, now it will complain about HUGIN_BUILDER. Set HUGIN_BUILDER to your name:
   HUGIN_BUILDER = your name
  • Configure again, and (hopefully) the last error about HUGIN_BUILDDATE. Set it to the current date:
   HUGIN_BUILDDATE = xx.xx.xxxx
  • Now press Configure, it should now run without error. And a last time Configure and then Generate.
  • Now open the INSTALL project file in SDKROOT\build-hugin, check that on the top there is selected RelWithDebInfo (not Release!!) and Win32 (for 32 bit Hugin) or x64 (for 64 bit Hugin). Now build the INSTALL project.