Obsolete instruction for building BornAgain installer with MSVC2015 CE (long version)

To install 32 bit

Install MSVC 2015 Community Edition
  • Download online installer and run it

If it's complains "The specified program requires a newer version of Windows." use following recipe

Right click (on the installer) -> Properties -> Compatibility -> Uncheck "Run this program in compatibility mode for" for all users

See http://stackoverflow.com/questions/34076414/installing-visual-studio-community-2015-on-windows-7-sp1

Install cmake

by running cmake-3.2.3-win32-x86.exe
select option "add cmake to the system PATH for all users"

Install NSIS

version NSIS 3.0b1

Install Qt5.6
  • Use online installer

Select 5.6 and msvc2015 32-bit and msvc2015 64-bit
Add to path c:\Qt\5.6\msvc2015\bin (be sure it precedes other locations where Qt dll's might be present, as for example the cmake path)
Create environment variable QTDIR=C:\Qt\5.6\msvc2015

Install Python
  • Install Anaconda Python 2.7 32bit

from http://continuum.io/downloads
For all users, into C:\Anaconda (this path is hard coded in Core/CMakeLists.txt to pick up Python27.dll)
let it modify PATH

Create directory C:\opt\local_x86

C:\opt\local_x86\include
C:\opt\local_x86\lib

Building boost
  • install zlib and bzip2

from http://www.zlib.net/ into C:\temp\zlib-1.2.8
from http://www.bzip.org/downloads.html into C:\temp\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

  • Compile boost

Download boost from http://sourceforge.net/projects/boost/files/boost/
Unpack boost_1_60_0.zip to C:\temp\boost_1_60_0
Run "MSBuild command prompt" from "Visual studio 2015 command tools"
cd C:\temp\boost_1_60_0
bootstrap.bat
b2 toolset=msvc-14.0 --build-type=complete --abbreviate-paths architecture=x86 address-model=32 install --prefix=c:\temp\boost_1_60_0_32bit -sBZIP2_SOURCE="C:\temp\bzip2-1.0.6" -sZLIB_SOURCE="C:\temp\zlib-1.2.8" variant=release link=shared threading=multi -j2

  • Copy boost

Copy or move directory c:\temp\boost_1_60_0_32bit\include\boost-1_60\boost to C:\opt\local_x86\include\boost
Copy or move content of c:\temp\boost_1_60_0_32bit\lib\* to C:\opt\local_x86\lib

Install fftw3

download fftw-3.3.4-dll32.zip and unpack into temporary directory C:\temp\fftw3
generate lib file

open "VS2015 Developer Command Prompt" from Windows menu All Programs/Microsoft Visual Studio 2015/Tools
cd C:\temp\fftw3
lib /def:libfftw3-3.def

copy c:\temp\fftw3\fftw3.h to C:\opt\local_x86\include\.
copy c:\temp\fftw3\libfftw3-3.lib to C:\opt\local_x86\lib\.
copy c:\temp\fftw3\libfftw3-3.def to C:\opt\local_x86\lib\.
copy c:\temp\fftw3\libfftw3-3.dll to C:\opt\local_x86\lib\.

Install GSL
  • Build and install GSL for Windows

Download GSL for Windows from https://github.com/ahmadyan/gnu-gsl-for-windows
Unpack to C:\temp\gsl-1.16
Open solution build.vc11\gsl.lib.sln in Visual Studio 2015 and Upgrade VCC Compiler and Libraries for all projects
Build solution with Release - Win32; if fatal errors appear, build projects separately
Copy directory C:\temp\gsl-1.16\gsl to C:\opt\local_x86\include\.
Copy content C:\temp\gsl-1.16\lib\Win32\Release\*.lib to C:\opt\local_x86\lib\.

Install TIFF
  • Download tiff-4.0.6.zip from http://download.osgeo.org/libtiff/
  • Unpack to C:\temp\libtiff-4.0.6
  • Comment out definition block (#if ... #endif) of snprintf in <source>\libtiff\tiffiop.h
  • cd C:\temp\libtiff-4.0.6, compile with "nmake /f makefile.vc"

Copy library file C:\temp\libtiff-4.0.6\libtiff\libtiff.dll to C:\opt\local_x86\lib\.
Copy library file C:\temp\libtiff-4.0.6\libtiff\libtiff.lib to C:\opt\local_x86\lib\.
Copy header files C:\temp\libtiff-4.0.6\libtiff\*.h to C:\opt\local_x86\include\libtiff\.

PATH
  • Add c:\opt\local_x86\lib to PATH
Build BornAgain for MSVC 2015
  • Change to build directory (in same parent folder as BornAgain source)

Adapt Core/CMakeLists.txt to use correct boost version and to find python27.dll (if python was not installed in C:\Anaconda\)
cmake -G "Visual Studio 14" -DCMAKE_INCLUDE_PATH=C:/opt/local_x86/include -DCMAKE_LIBRARY_PATH=C:/opt/local_x86/lib -DCMAKE_BUILD_TYPE=Release ../BornAgain
cmake --build . --config Release

Making binary installer
  • After build is complete, installer is generated by running in the build directory the command

CPack -C Release

To install 64 bit

The following steps are exactly like for the 32 bit build:

Install MSVC 2015 Community Edition
Install cmake
Install NSIS

For the following steps, we need to make sure to install/build 64 bit versions:

Install Qt5.6
  • Use online installer (as for 32 bit)

Select 5.6 and msvc2015 32-bit and msvc2015 64-bit
Add to path c:\Qt\5.6\msvc2015_64\bin
Create environment variable QTDIR=C:\Qt\5.6\msvc2015_64

Install Python
  • Install Anaconda Python 2.7 64bit

from http://continuum.io/downloads
For all users, into C:\Anaconda (this path is hard coded in Core/CMakeLists.txt to pick up Python27.dll)
let it modify PATH

Create directory C:\opt\local_x64

C:\opt\local_x64\include
C:\opt\local_x64\lib

Building boost
  • install zlib and bzip2

from http://www.zlib.net/ into C:\temp\zlib-1.2.8
from http://www.bzip.org/downloads.html into C:\temp\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

  • Compile boost

Download boost from http://sourceforge.net/projects/boost/files/boost/
Unpack boost_1_60_0.zip to C:\temp\boost_1_60_0
Run "MSBuild command prompt" from "Visual studio 2015 command tools"
cd C:\temp\boost_1_60_0
bootstrap.bat
b2 toolset=msvc-14.0 --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install --prefix=c:\temp\boost_1_60_0_64bit -sBZIP2_SOURCE="C:\temp\bzip2-1.0.6" -sZLIB_SOURCE="C:\temp\zlib-1.2.8" variant=release link=shared threading=multi -j2

  • Copy boost

Copy or move directory c:\temp\boost_1_60_0_64bit\include\boost-1_60\boost to C:\opt\local_x64\include\boost
Copy or move content of c:\temp\boost_1_60_0_64bit\lib\* to C:\opt\local_x64\lib

Install fftw3

download fftw-3.3.4-dll64.zip and unpack into temporary directory C:\temp\fftw3_64
generate lib file

open "VS2015 Developer Command Prompt" from Windows menu All Programs/Microsoft Visual Studio 2015/Tools
cd C:\temp\fftw3_64
lib /def:libfftw3-3.def

copy c:\temp\fftw3_64\fftw3.h to C:\opt\local_x64\include\.
copy c:\temp\fftw3_64\libfftw3-3.lib to C:\opt\local_x64\lib\.
copy c:\temp\fftw3_64\libfftw3-3.def to C:\opt\local_x64\lib\.
copy c:\temp\fftw3_64\libfftw3-3.dll to C:\opt\local_x64\lib\.

Install GSL
  • Build and install GSL for Windows

Download GSL for Windows from https://github.com/ahmadyan/gnu-gsl-for-windows
Unpack to C:\temp\gsl-1.16
Open solution build.vc11\gsl.lib.sln in Visual Studio 2015 and Upgrade VCC Compiler and Libraries for all projects
Build solution with Release - x64; if fatal errors appear, build projects separately
Copy directory C:\temp\gsl-1.16\gsl to C:\opt\local_x64\include\.
Copy content C:\temp\gsl-1.16\lib\x64\Release\*.lib to C:\opt\local_x64\lib\.

Install TIFF
  • Download tiff-4.0.6.zip from http://download.osgeo.org/libtiff/
  • Unpack to C:\temp\libtiff-4.0.6
  • Comment out definition block (#if ... #endif) of snprintf in <source>\libtiff\tiffiop.h
  • cd C:\temp\libtiff-4.0.6, compile with "nmake /f makefile.vc BUILD64BIT=1" (if the 32 bit build is still there, first do "nmake /f Makefile.vc clean"

Copy library file C:\temp\libtiff-4.0.6\libtiff\libtiff.dll to C:\opt\local_x64\lib\.
Copy library file C:\temp\libtiff-4.0.6\libtiff\libtiff.lib to C:\opt\local_x64\lib\.
Copy header files C:\temp\libtiff-4.0.6\libtiff\*.h to C:\opt\local_x64\include\libtiff\.

PATH
  • Add c:\opt\local_x64\lib to PATH
Build BornAgain for MSVC 2015
  • Change to build directory (in same parent folder as BornAgain source)

Adapt Core/CMakeLists.txt to use correct boost version and to find python27.dll (if python was not installed in C:\Anaconda\)
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INCLUDE_PATH=C:/opt/local_x64/include -DCMAKE_LIBRARY_PATH=C:/opt/local_x64/lib -DCMAKE_BUILD_TYPE=Release ../BornAgain
cmake --build . --config Release

Making binary installer
  • After build is complete, installer is generated by running in the build directory the command

CPack -C Release