Instruction for building BornAgain installer with Visual Studio 2017 CE (long version) » History » Version 1

Version 1/7 - Next » - Current version
herck, 18 Oct 2017 16:12


Instruction for building BornAgain installer with Visual Studio 2017 CE (long version)

Install MSVC 2017 Community Edition
  • Download online installer and run it
Install cmake

select option "add cmake to the system PATH for all users"

Install NSIS

version NSIS 3.02.1

Install Qt5.9.2
  • Use online installer

Select 5.9.2 and msvc2017 64-bit
Add to path c:\Qt\5.9.2\msvc2017_64\bin
Create environment variable QTDIR=C:\Qt\5.9.2\msvc2017_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.11
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_65_1.zip to C:\temp\boost_1_65_1
Run "x64 Native Tools Command Prompt for VS 2017"
cd C:\temp\boost_1_65_1
bootstrap.bat
b2 toolset=msvc-14.1 --build-type=complete --abbreviate-paths architecture=x86 address-model=64 install --prefix=c:\temp\boost_1_65_1_64bit -sBZIP2_SOURCE="C:\temp\bzip2-1.0.6" -sZLIB_SOURCE="C:\temp\zlib-1.2.11" variant=release link=shared threading=multi -j2

  • Copy boost

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

Install fftw3

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

open "x64 Native Tools Command Prompt for VS 2017"
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 2017 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.8.zip from http://download.osgeo.org/libtiff/
  • Unpack to C:\temp\libtiff-4.0.8
  • Comment out definition block (#if ... #endif) of snprintf in <source>\libtiff\tiffiop.h
  • cd C:\temp\libtiff-4.0.8, compile with "nmake /f makefile.vc BUILD64BIT=1"

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

Install Yaml-cpp

cmake -G "Visual Studio 15 2017 Win64" -DBUILD_SHARED_LIBS=ON ..
cmake --build . --config Release
Copy header files C:\temp\yaml-cpp\include\yaml-cpp to C:\opt\local_x64\include\yaml-cpp
Copy library files C:\temp\yaml-cpp\build\Release\* to C:\opt\local_x64\lib\

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

Adapt Core/CMakeLists.txt to find python27.dll (if python was not installed in C:\Anaconda\)
cmake -G "Visual Studio 15 2017 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