This is an old revision of the document!


Windows

Download and run the installer that best fits your system (32bit or 64bit).

Older versions are available on Google Code. Because Google does not allow new uploads anymore the installers starting from January 2014 are available from Bitbucket.

Photivo for Windows has a portable mode. See below for more information.

Portable Mode

Portable mode makes it possible to carry Photivo around on a USB drive or SD card by keeping all program files and settings together in one place.

To enable portable mode create a file called use-portable-profile (just like this, no file extension) in Photivo’s program folder (where photivo.exe is located). The content of that file is not important, it can be completely empty.

When use-portable-profile is present Photivo stores all user data (settings, presets etc.) inside its program folder instead of in your user application data folder.

Compiling Photivo

This section covers compiling 32bit and/or 64bit Photivo binaries on a Windows machine with MinGW.

We offer a precompiled toolchain for 64bit Windows. More information: Precompiled Win7 64bit toolchain.

This guide is mainly maintained by Brother John.

Toolchain

For this guide I assume C:\tc (for toolchain) as the base folder for your build environment. You can use any folder you like but avoid special characters in the name, especially spaces. If your file system is NTFS go to the folder’s security properties and make sure you have full access.

Also, it’s a good idea to set up two completely separate installations for 32bit and 64bit compilation. Yes, TDM64 can also create 32bit binaries but you don’t want to have both 32bit and 64bit libraries lying around in the same folder tree unless you’re extremely fond of utter chaos. :-)

TDM GCC

Tested: version 4.7.1
URL: http://tdm-gcc.tdragon.net/download

This is the core of the toolchain containing MinGW and gcc. Get the 32bit and/or 64bit bundle installer.

  • Do not use C:\MinGW as your MinGW installation folder!
  • Install TDM 64bit, e.g. to C:\tc\tdm-471-x64. Enable openmp during setup.
  • Install TDM 32bit, e.g. to C:\tc\tdm-471-x86. Enable openmp and sjlj unwinding during setup.

For clarity I’ll only refer to C:\tc\tdm-471-x64 from now on when talking about the real MinGW path.

Because we love C++11 TDMs older than 4.6.1 – or in general any GCC prior to 4.6 – is not able to compile Photivo.

Msys

Tested: version 1.0.11
URL: http://downloads.sourceforge.net/mingw/MSYS-1.0.11.exe

Msys provides a Linux like shell on Windows. Since the whole toolchain is Linux stuff dragged over to Windows, life with Msys is a lot easier than using the native Windows shell. Exception: Compiling Qt, but more on that later.

Install Msys to C:\tc\tdm-471-x64\msys and/or a second time to C:\tc\tdm-471-x86\msys and during the setup choose different start menu folders so you have one each for 64bit and 32bit. Depending on which Msys you start, 64bit or 32bit binaries will be created.

From inside of Msys you can access the associated MinGW folder as /mingw.

cmake

Tested: version 2.8.9
URL: http://www.cmake.org/cmake/resources/software.html

cmake is the more modern counterpart to configure. Both are used to prepare source code for compiling with make.

Download the “Windows ZIP” package and unpack to /mingw.

Subversion

Exact version is not essential. Just make sure to use a recent one.
URL: http://www.sliksvn.com/en/download

Needed to access subversion source code repositories. The URL from above is for the command line installer. You can also use a graphical frontend like the great TortoiseSVN.

Mercurial

Exact version is not essential. Just make sure to use a recent one.
URL: http://mercurial.selenic.com/downloads/

Mercurial like Subversion is a version control system. It’s the system Photivo uses, so you need Mercurial (or Hg for short) to access the Photivo source code.

Download and install the Windows command line setup (MSI version recommended). If you already have Mercurial or a graphical tool like ToroiseHg installed, that will work as well. In fact, TortoiseHg includes the complete Hg command line program.

Perl

Exact version is not essential. Just make sure to use a recent one.
URL: http://www.activestate.com/activeperl/downloads

Perl is required by Qt’s configure (starting with v4.8.0). The installer gives you the option to add Perl to your path environment variable so you can access it directly from anywhere. For our purposes that is not necessary. On the other hand it doesn’t really hurt, but I prefer to keep my path as clean as possible.

If you’re on Windows 64bit it doesn’t matter if you install the 32bit or 64bit version. Both work.

pkg-config

URL: http://sourceforge.net/projects/pkgconfiglite/files/

Pkg-config is a tool for software (source code) library configuration management. Download the latest binary archive and unpack to /mingw.

Setting Things Up

Build Folders

Like with separating the 32bit and 64bit toolchains it’s also a good idea to keep MinGW’s folders clean of your own compiled binaries and accompanying header files etc. I assume you’re going to put all our own stuff into a folder called /my. Of course you can use any name you like. As usual, avoid special characters and spaces. Creating a separate build folder is essential. You will run into trouble if you don’t do it.

The /my folder must be a sibling of /mingw, otherwise the linker might not find necessary libraries. For example, that problem occurred with GLib. Your real path structure should look something like this:

C:\tc
    tdm-471-x64
        mingw    this is /mingw from inside Msys
        msys     this is / from inside Msys
        my       this is /my from inside Msys

To setup the paths correctly, open your C:\tc\tdm-471-x64\msys\etc\fstab file and add a line that defines /my as

C:/tc/tdm-471-x64/my    /my

A line defining /ming in a similar fashing should already be present.

Also open C:\tc\tdm-471-x64\msys\etc\profile and add /my/bin to the two export PATH=… lines.

Then start Msys and create the folder and the necessary subfolders.

mkdir /my
cd /my
mkdir bin include lib src

I assume that all sources we’re about to compile are located in subfolders of /my/src, e.g. something like /my/src/jpeg-8a for LibJpeg etc. Always change into the appropriate subfolder before starting compilation.

Because by default our build environment does not know about the custom folder, you need to specify it to the compiler and linker. Do this by setting these environment variables in MSys.

export LDFLAGS=-L/my/lib
export CFLAGS="-I/my/include -O3"
export CXXFLAGS="-I/my/include -O3"
export PKG_CONFIG_PATH=/my/lib/pkgconfig

Since it’s easy to forget setting these again every time you start Msys, automate it by putting the three lines into your profile file. Repeat for 32bit. Then start Msys and check if the flags really are set. This command

set | egrep "FLAGS|PKG"

must output all four variables.

GNU gettext

Tested: version 0.18.1.1
URL 64bit: http://ftp.gnome.org/pub/gnome/binaries/win64/dependencies/
URL 32bit: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/

Gettext is used to translate software into multiple languages. It is completely separate from the system Photivo itself uses – the one provided by the Qt framework – but some of our dependencies rely on gettext.

To get the binaries and development files download both the latest gettext-runtime and gettext-runtime-dev archives and unpack to /my.

As far as building from source is concerned I gave up on gettext. It is more than I can bear and keep my sanity. If someone can explain to me how to build gettext on Windows in a MinGW/Msys environment, I’d be really grateful.

glib

Tested: version 2.26.1 (64bit) and 2.28.8 (32bit)
URL 64bit: http://ftp.gnome.org/pub/gnome/binaries/win64/glib/
URL 32bit: http://ftp.gnome.org/pub/gnome/binaries/win32/glib/

Glib is a utility library originating from GTK+. Lensfun relies on it.

To get the binaries and development files download both the latest glib and glib-dev archives and unpack to /my.

I might revisit glib later. Building it on Windows seems doable with a bit of effort, just being too lazy right now.

Packages to Compile

Compile the packages in the order below because sometimes later packages depend on earlier ones to be present.

To use all your CPU cores for compiling use the -jX option of make where X stands for the numbers of threads to use. All command lines below are given for a quad-core processor, i.e. they use

make -j4

This tutorial focusses on release versions of all the packages. If you need debug versions consult the notes below before you continue.

Qt Framework

Tested: version 4.8.2
URL: http://releases.qt-project.org/qt4/source/

Get the latest 4.x qt-everywhere archive and unpack to /my/src. I had some problems with Qt 4.8.3, but 4.8.2 and 4.8.4 work fine.

If you never intend to use your toolchain for anything else than Photivo you may follow the quicker Photivo-only compilation because Photivo does not need all of Qt, e.g. Phonon or Webkit aren’t used. Building a complete Qt takes significantly longer but you won’t run into problems with missing components should you build something else than Photivo.

The configure options -qt-style-windowsxp -qt-style-windowsvista are necessary for 64bit to enable the special style engines of Win XP and newer. Without these options 64bit Photivo will appear in the old and ugly Win95 look. 32bit does not have that problem but the options do not hurt either.

You might run into problems early in the build process with an error about an unknown option -static-libstdc++. If that happens go to the qmake subfolder of your Qt sources and remove that option from the file Makefile.win32-g++.

Complete Qt

I did not manage to compile Phonon from inside Msys. Webkit is also a trouble maker. That’s why we’ll build Qt from a normal Windows command prompt instead. Unfortunately multithreading does not work in that environment, so building will be slow. Take two hours as a rough estimate.

Open a command prompt and set the compiler flags.

set CFLAGS=-O3
set CXXFLAGS=-O3

MinGW’s and Perl’s bin folders must be in the path. Add with their correct paths for your system and don’t forget to adjust for the 64bit and 32bit toolchains.

set path=%path%;C:\tc\tdm-471-x64\bin\;C:\Program Files\Perl\bin

Then cd to you Qt folder and configure:

configure.exe -release -no-declarative-debug -opensource -shared -fast -phonon -no-qt3support -no-dsp -no-vcproj -qt-style-windowsxp -qt-style-windowsvista -nomake examples -nomake demos -nomake tools

If you want/need the backwards compatibility stuff for the old Qt 3 remove the -no-qt3support switch. Configure takes a couple of minutes until it’s done building some basic components, e.g. qmake. When it’s finished start the real work with

mingw32-make

and go get a big mug of coffee.

Photivo-only Qt

This one can be built from Msys.

./configure.exe -opensource -shared -release -fast -no-opengl -qt-style-windowsxp -qt-style-windowsvista -nomake examples -nomake demos -nomake tools -no-qt3support -no-openssl -no-dsp -no-vcproj -no-phonon -no-phonon-backend -no-webkit -no-script -no-scripttools
make -j2

Keep make at two threads for Qt. In my experience compilation tends to hang at some point with more threads. If you encounter that problem abort and re-run make with fewer threads.

Finishing up

I keep Qt in a separate folder but add its bin folder to the search path for easy access to qmake & Co. To do this, open your Msys profile file (see above) and add this line:

export PATH=$PATH:/my/src/qt/bin

Adjust the path name if necessary! Restart Msys to enable the changes.

The C++ standard library is linked dynamically, i.e. qmake needs to find the libgcc and libstdc++ DLLs. That’s not a problem as long as you’re inside Msys, so Photivo will compile fine. But keep it in mind if you need to use qmake outside of Msys.

zlib

Tested: version 1.2.7
URL: http://zlib.net/

make -f win32/Makefile.gcc
'cp' -v zlib1.dll /my/bin
'cp' -v zconf.h zlib.h /my/include
'cp' -v libz.a /my/lib
'cp' -v libz.dll.a /my/lib/libz.dll.a

LibPNG

Tested: version 1.5.12
URL: http://www.libpng.org/pub/png/libpng.html

Download the configure based package, i.e. the .tar.gz or .tar.xz archive. Avoid the .zip. Then compile normally.

./configure --prefix=/my
make -j4
make install

LibJpeg

Tested: version 8d
URL: http://www.ijg.org/

Versions up to and including 8a compile normally. For later versions use this approach:

Run configure normally.

./configure --prefix=/my

Then edit the generated jconfig.h file. At the beginning of the file replace the line

#undef HAVE_PROTOTYPES

with

#define HAVE_PROTOTYPES 1

Save jconfig.h and continue normally.

make -j4
make install

LibTIFF

Tested: version 4.0.3
URL: ftp://ftp.remotesensing.org/pub/libtiff/

LibTIFF has the same problem with the basetsd.h file as GraphicsMagick. See below how to solve it.

./configure --prefix=/my
make -j4
make install

Lcms2

Tested: version 2.4
URL: http://sourceforge.net/projects/lcms/files/lcms/

./configure --prefix=/my
make -j4
make install

Libiconv

Tested: version 1.14
URL: http://www.gnu.org/software/libiconv/

Before compiling change the .rc files according to these instructions:

First, we need to edit the .rc files in the 'windows' directories:
Comment out lines 6-8, 25 & 31 in 'windows\libiconv.rc' and 'windows\iconv.rc'

Then compile normally.

./configure --prefix=/my
make -j4
make install

Expat

Tested: version 2.0.1
URL: http://sourceforge.net/projects/expat/files/expat/

Compile normally.

./configure --prefix=/my
make -j4
make install

Exiv2

Tested: SVN revision 2656 (2012-01-20)
URL: http://www.exiv2.org/download.html

The exiv2 source package from the exiv2 homepage used to be extremely problematic to compile on Win64. I don’t know if this is still the case. We’ll use the SVN trunk instead! The SVN version uses cmake while the archive from the homepage is configure based.

Checkout the exiv2 repository. I did not manage to build the latest revision. If you still want to try, remove the -r 2656 from the command line.

svn checkout -r 2656 svn://dev.exiv2.org/svn/trunk

Then build with cmake.

mkdir build
cd build
cmake .. -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/my -DCMAKE_BUILD_TYPE=release
make -j4
make install

fftw

Tested: version 3.3.2
URL: ftp://ftp.fftw.org/pub/fftw/

./configure --prefix=/my --enable-shared --disable-static --enable-sse2 --enable-threads --with-combined-threads --with-our-malloc16
make -j4
make install

GraphicsMagick

Tested: snapshot version 1.4.0 2012-09-30
ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/snapshots/

GraphicsMagick has problems with MinGW, i.e. make fails. Problem was postet on the GraphicsMagick forum. But there is a workaround.

64bit
Comment out lines 30–31 and 34–35 in /mingw/x86_64-w64-mingw32/include/basetsd.h.

typedef signed char INT8,*PINT8;
typedef signed short INT16,*PINT16;

and

typedef unsigned char UINT8,*PUINT8;
typedef unsigned short UINT16,*PUINT16;

32bit
Comment out lines 56–57 in /mingw/include/basetsd.h.

typedef unsigned char UINT8;
typedef unsigned short UINT16;

Then compile.

./configure --prefix=/my --enable-shared --with-quantum-depth=16 --disable-static --without-modules --without-perl
make -j4
make install
'cp' -r /my/include/GraphicsMagick/* /my/include

After you have built GraphicsMagick don’t forget to change basetsd.h back to its original state.

LibLqr (liquid rescale)

Tested: version 0.4.1
URL: http://liblqr.wikidot.com/en:download-page

./configure --prefix=/my
make -j4
make install

Lensfun

Tested: version 0.2.6
URL: http://lensfun.berlios.de/

With the current version 0.2.8 the workarounds described below are no longer necessary. For now I’m not removing them from this page because Lensfun 0.2.8 hasn’t really been tested with Photivo.

Lensfun’s cmake build system is still in its infancy and does not detect our glib correctly. To work around you need to change two files.

In the main CMakeLists.txt (the one in Lensfun’s »root« folder) comment out or delete line 150 that reads originally:

INSTALL(FILES ${GLIB2_DLL} DESTINATION ${BINDIR})

In build/CMakeModules/FindGLIB2.cmake replace the entire contents of the file with:

INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE( GLIB2 REQUIRED glib-2.0 )
IF (NOT GLIB2_FOUND AND GLIB2_FIND_REQUIRED)
        MESSAGE(FATAL_ERROR "Could not find glib2")
ENDIF()

Also open libs/regex/tre-match-utils.h and in lines 177 and 203 remove the inline keyword. Then compile with cmake:

mkdir cbuild
cd cbuild
cmake .. -G "MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=/my -DCMAKE_BUILD_TYPE=release -DBUILD_TESTS=OFF -DBUILD_FOR_SSE2=ON
make -j4
make install
'cp' /my/src/lensfun/bin/liblensfun.dll /my/bin
'cp' /my/src/lensfun/include/lensfun/lensfun.h /my/src/lensfun/include/regex/regex.h /my/include
'cp' /my/src/lensfun/lib/* /my/lib
mkdir -p /my/share/lensfun
'cp' /my/src/lensfun/share/lensfun/* /my/share/lensfun

make install will install its files to the wrong location. Don’t worry about it. The commands afterward copy everything to its proper place.

Building Photivo

Finally you are ready to build Photivo itself.

Gimp Plugin

Tested: version 2.6.4
URL 64bit: gimp-dev-2.6.4-amd64.zip
URL 32bit: gimp-dev-2.6.4.zip

For the Gimp plugin download the gimp-dev package for and unpack to /my. Note that only Gimp determines the needed plugin. 64bit Gimp needs the 64bit plugin and 32bit Gimp needs the 32bit plugin.

64bit ptGimp.exe compiles but produces linker errors. :-( If you know how to successfully build the 64bit plugin, contact us!

Compiling

First you need to clone the Photivo source code repository to your hard drive and update to the latest revision in the trunk.

cd /my/src
hg clone https://photivo.googlecode.com/hg/ photivo
cd photivo
hg update default

Then compile. See below for Photivo specific qmake options.

mkdir build
cd build
qmake ../photivo.pro
make -j4

Photivo has some custom options that control which subprojects are compiled. Photivo itself is always compiled. Also enabled by default are ptClear (the mini tool to reset settings) and the Gimp plugin. Disabled are the Adobe profiles creator and the Curves creator; end users do not need those two. You can specify which subprojects to build by modifying qmake’s CONFIG variable. The qmake example below demonstrates all available options.

qmake CONFIG+=WithoutClear CONFIG+=WithoutGimp CONFIG+=WithAdobeProfiles CONFIG+=WithCurves ../photivo.pro

For later updates download the changes from the repository.

cd /my/src/photivo
hg pull
hg update default

Then compile as above.

cd build
qmake ../photivo.pro
make -j4

Re-compiling all the dependencies is usually not necessary.

Binary Package for Photivo 64bit

Photivo needs a variety of libs and other files and folders. We need to find all the pieces and create a functional package in a new folder.

  • from the Photivo build folder /my/src/photivo/build
    • photivo.exe
    • ptClear.exe
  • these subfolders from the Photivo source folder /my/src/photivo
    • ChannelMixers
    • Curves
    • LensfunDatabase
    • Presets
    • Profiles
    • Translations
    • UISettings
  • from /my/src/qt/bin
    • QtCore4.dll
    • QtGui4.dll
    • QtNetwork4.dll
  • from /mingw/bin
    • libgcc_s_sjlj_64-1.dll
    • libgomp_64-1.dll
    • libstdc++_64-6.dll
    • pthreadGC2_64.dll
  • from /my/bin
    • libexiv2.dll
    • libexpat-1.dll
    • libfftw3-3.dll
    • libglib-2.0-0.dll
    • libGraphicsMagick-3.dll
    • libGraphicsMagick++-3.dll
    • libGraphicsMagickWand-2.dll
    • libiconv-2.dll
    • libintl-8.dll
    • libjpeg-8.dll
    • liblcms2-2.dll
    • liblensfun.dll
    • liblqr-1-0.dll
    • libpng15-15.dll
    • libtiff-5.dll
    • zlib1.dll

That’s it. You now have a complete Photivo 64bit Windows package. For the Gimp plugin you only need two files:

  • ptGimp.exe (from the build folder)
  • QtCore4.dll

Binary Package for Photivo 32bit

From the Photivo and Qt folders and for the Gimp plugin you need the same files as above for 64bit, but of course the 32bit versions. The files from /mingw/bin and /my/bin are different:

  • from /mingw/bin
    • libgcc_s_sjlj-1.dll
    • libgomp-1.dll
    • libstdc++-6.dll
    • pthreadGC2.dll
  • from /my/bin
    • intl.dll
    • libexiv2.dll
    • libexpat-1.dll
    • libfftw3-3.dll
    • libglib-2.0-0.dll
    • libGraphicsMagick-3.dll
    • libGraphicsMagick++-3.dll
    • libGraphicsMagickWand-2.dll
    • libiconv-2.dll
    • libjpeg-8.dll
    • liblcms2-2.dll
    • liblensfun.dll
    • liblqr-1-0.dll
    • libpng15-15.dll
    • libtiff-5.dll
    • zlib1.dll

Notes on building debug libraries

You only need debug libraries if you want to get involved in Photivo’s development (don’t hesitate!) or if you’d like to get really serious with finding bugs (don’t hesitate either!).

To enable debug symbols you pass the -g switch to gcc. Also you should disable optimizations. Set your CFLAGS and CXXFLAGS accordingly:

export CFLAGS="-I/my/include -O0 -g"
export CXXFLAGS="-I/my/include -O0 -g"

For most of the libraries this is enough to enable debug support. There are some exceptions, though.

  • Qt: When running configure exchange the -release switch for -debug-and-release (if you want both debug and release DLLs) or -debug (if you want debug DLLs only). Also remove the -no-declarative-debug option.
  • Exiv2: When running cmake use -DCMAKE_BUILD_TYPE=debugfull instead of -DCMAKE_BUILD_TYPE=release.
  • GraphicsMagick: Add --disable-openmp to the configure options, otherwise you’ll run into a segfault when debugging.

I also found that setting up yet another separate toolchain for debug builds helps greatly to avoid problems and chaos.