Windows build » History » Version 59

« Previous - Version 59/98 (diff) - Next » - Current version
herck, 05 Jun 2014 11:58

Windows build

Experimental compilation under Windows using Microsoft Visual Studio or Mingw.
For those who want to see the devil developers only.

In the next sections we explain

  • Building of BornAgain using Microsoft Visual Studio 2012 (MSVC2012)

Works fully for Debug/Release versions of: Core + Fit + UnitTests + FunctionalTests + App + GUI

  • Making Windows installer package using results of MSVC2012 build
  • Building of BornAgain using using Mingw

Works partially for Debug/Release vesions of: Core + Fit + UnitTests + FunctionalTests

Before we start

Install optional packages for happier life
  • Atlassian SourceTree (v0.9.2.3)

  • Kate from KDE

  • far manager

  • WinSCP

  • Dependency Walker

MSVC2012 build

Install VS.NET2012
  • Install Visual Studio using our VS.NET2012 package

Install En language pack

Switch En ON by going into TOOLS/optionen -> Umgebung/Internationale Einstellungen ;)

install "stop build on error" plugin

Install Qt
  • Install Qt 5.1.1

Download and install Qt 5.1.1 for Windows 32-bit (VS 2012) from to C:\Qt
Add to PATH C:\Qt\5.1.1\msvc2012\bin
Create environment variable QTDIR=C:\Qt\5.1.1\msvc2012

Install cmake
Install NSIS
  • NSIS will be used after compilation for the generation of installation package

install NSIS from

Install Python and Co
  • install 32bit Python version 2.7

install through into default C:/Python27

  • install numpy

e.g. numpy-1.8.0-win32-superpack-python2.7.exe from

  • install matplotlib

e.g. matplotlib-1.3.1.win32-py2.7.exe from

  • matplotlib also depends on a number of packages: pyparsing, dateutil, six

install them from unofficial by running


  • Optional installation of debug version of python libraries

Instruction was found at
Download Python source
Open <path to source>/PCbuild/pcbuild.sln in MSVC2012
Compile, some of projects will fail, no matter
PCbuild folder will contain the files

python27_d.dll, python27_d.lib, python27_d.pdb, python27_d.exp

copy the dll to C:\Python27 and the remaining 3 files to C:\Python27\libs

  • You can use some all-in-one Python pack which contain all required Python libraries

We have tested successfully PythonXY pack from

Comment about installation of additional libraries

All further installations should end up in C:\opt\local_vc110

Install gsl

succeeded only for static build using "gslhdrs step" mentioned in gsl.vc11.readme

for shared build there were undefined symbols in dll needed for minimization

Install fftw3

from download
unpack archive somewhere
copy fftw3.h to C:\opt\local_vc110\include
copy libfftw3-3.dll and libfftw3-3.def to C:\opt\local_vc110\lib
generate corresponding lib file

open "VS2012 x86 native tools command prompt"
run there "lib /def:libfftw3-3.def" to generate lib file

install BOOST
  • install zlib and bzip2

from into C:/opt/local_vc110/source/zlib-1.2.8
from into C:/opt/local_vc110/source/bzip2-1.0.6

Patch bzip2 installation (MSVC specific!)
Namely delete first line ("LIBRARY LIBBZ2") from file libbz2.def
This will remove unnecessary dependency from external bzip2 during later linking of boost libraries into other project

  • Download and compile boost_1_54_0

from and unpack
Run VS2012 x86 native tools command prompt
b2 install --prefix=c:/opt/local_vc110 -sBZIP2_SOURCE="C:\opt\local_vc110\source\bzip2-1.0.6" -sZLIB_SOURCE="C:\opt\local_vc110\source\zlib-1.2.8" variant=release link=static,shared threading=multi
Move c:/opt/local_vc110/include/boost_1.54/boost directory into c:/opt/local_vc110/include/boost

  • Add c:\opt\local_vc110\lib to PATH
Working with MSVC2012
  • generate project file

Create build directory BornAgain-build and run there cmake command from command line
cmake -G "Visual Studio 11" -DCMAKE_INCLUDE_PATH=C:/opt/local_vc110/include -DCMAKE_LIBRARY_PATH=C:/opt/local_vc110/lib ../BornAgain
Open BornAgain.sln in Visual Studio

There will be several projects in the solution (INSTALL, ZERO_CHECK, etc), all are necessary. Select build type "Release" and do "BUILD/Build Solution"
Functional tests can be runned additionally by building "check" project
Installation procedure can be tested by building INSTALL project

Windows installer

Installer can be generated using result of MSVC build
For the generation CMake -> CPack -> NSIS combination is used.

How to create installer
  • After build is complete, installer is generated by running in the build directory the command

CPack -C Release

  • Only MSVC build based installer have been validated so far.
How to use installer on another PC
  • Install Python + Numpy + matplotlib
  • Download installer from the link below this page, run it
  • Navigate to the installation directory and double click on Examples/python/ex001_CylindersAndPrisms/
  • Navigate to the installation directory and double click on coregui.exe

Mingw build

  • With Mingw we are able to compile(Core + Fit + UnitTests + FunctionalTests)

No App, GUI compilation is possible for the moment due to ROOT

Install Qt
  • Install Qt 5.1.1 for Windows 32-bit (MinGW 4.8, OpenGL)

from ttp:// into C:\Qt
Add to PATH C:\Qt\Tools\mingw48_32\bin;C:\Qt\Tools\mingw48_32\lib;C:\Qt\5.1.0\mingw48_32\bin;C:\Qt\Tools\QtCreator\bin

this will allow usage of mingw from any command line

Install cmake
  • install cmake as explained
Install MinGW
  • We need full MinGW suite to compile latest libgsl. MinGW from Qt installation want help.

download mingw-get-setup.exe installation manager from
run installer, there will be some pre selection of packages (from MinGW Base system, MSYS and GCC), should be enough
in the menu do Installation/Apply changes, then accept default C:\MinGW as an installation directory

Install Python and Co
  • as explained
Comment about installation of additional libraries

All further installations should end up in C:\opt\local

Install gsl
  • use previously installed MinGW to compile gsl

create empty directory c:\gsl-1.16
download source gsl-1.16.tar.gz from
copy unpacked directory to C:\mingw\msys\1.0\home\pospelov
run c:\mingw\msys\msys.bat which will bring command line prompt
there, navigate to c:\mingw\msys\1.0\home\pospelov\gsl-1.16

./configure --enable-static=yes --enable-shared=yes --prefix=/c/gsl-1.16
make install

copy directory "C:\gsl-1.16\include\gsl" to "C:\opt\local\include\gsl"
copy files libgsl-0.dll and libgslcblas-0.dll into "C:\opt\local\lib"

Install fftw3

from download
unpack archive somewhere
copy fftw3.h to C:\opt\local\include
copy libfftw3-3.dll and libfftw3-3.def to C:\opt\local\lib

install BOOST
  • install zlib and bzip2

from into C:/opt/local/source/zlib-1.2.8
from into C:/opt/local/source/bzip2-1.0.6

  • Download and compile boost_1_54_0

from and unpack
bootstrap.bat mingw
b2 install --prefix=c:/opt/local toolset=gcc -sBZIP2_SOURCE="C:\opt\local\source\bzip2-1.0.6" -sZLIB_SOURCE="C:\opt\local\source\zlib-1.2.8" address-model=32 variant=release link=static,shared threading=single,multi
Move c:/opt/local/include/boost_1.54/boost directory into c:/opt/local/include/boost

  • Add c:\home\pospelov\development\git\BornAgain\lib;c:\opt\local\lib to PATH
Running Mingw build
  • Create build directory and run there

cmake -G "MinGW Makefiles" ../BornAgain
mingw32-make -j4
mingw32-make check

or cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ../BornAgain

  • Generate installer

CPack -C Release