<!--toc-->
|
## Introduction
|
|
In general build on Windows using Microsoft Visual Studio is quite complex due to several factors:
|
|
1. Lack of easily accessible already build libraries in both debug and release variants for your MSVC version
|
2. Need of strict debug/release separation
|
|
|
So in order to make your life while building CppCMS simpler I suggest following rules:
|
|
1. Keep strict separation of debug and release installations and 32/64 bit architectures, for example
|
|
c:\cppcms_deps\x64\Debug
|
c:\cppcms_deps\x64\Release
|
c:\cppcms_deps\x86\Debug
|
c:\cppcms_deps\x86\Release
|
|
Note: pcre, icu and zlib support debug/release mangling of the libraries/dlls for debug/release flavor, but OpenSSL does not. So I strongly recommend to use separate trees to ensure safety.
|
|
2. When building with CMake always use "NMake Makefiles" generator to prevent collisions of debug/release methods
|
3. Start from basic dependencies zlib and pcre that can be built using CMake than go with more complex ones like OpenSSL and ICU if needed.
|
|
## Basic Dependencies:
|
|
1. Install CMake, make sure it is in global path
|
2. Install Python 2.x version, make sure it is in global path
|
3. Optionally install git if you want to build upstream branches.
|
|
|
### Building PCRE
|
|
PCRE comes with CMake build system, however building it correctly may be somewhat tricky.
|
|
Download the latest version of PCRE 8.x. Do not use PCRE2, it isn't supported.
|
|
Important options to note:
|
|
1. Make sure you explicitly specify Release/Debug flavor `-DCMAKE_BUILD_TYPE=Release`
|
2. Build Shared version of PCRE (i.e. dll) `-DBUILD_SHARED_LIBS=ON`
|
3. Make sure you put `-DPCRE_SUPPORT_UNICODE_PROPERTIES=ON` option on to enable utf-8 support - otherwise regex tests will fail
|
4. Use "NMake Makefiles" generator, default generator is multi version and much trickier to use.
|
|
Step by step:
|
|
Open Visual studio command prompt, for example `x64 Native Tools Command Prompt for VS 2017` or `x86 Native Tools Command Prompt for VS 2017` and change directory to location of PCRE sources. Create build directory and run the commands:
|
|
For example for x64 release build
|
|
mkdir msvc-release-x64
|
cd msvc-release-x64
|
cmake -DBUILD_SHARED_LIBS=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=c:\cppcms_deps\x64\Release ..
|
nmake
|
nmake install
|
cd ..
|
|
Debug
|
|
mkdir msvc-debug-x64
|
cd msvc-debug-x64
|
cmake -DBUILD_SHARED_LIBS=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=c:\cppcms_deps\x64\Debug ..
|
nmake
|
nmake install
|
cd ..
|
|
|
### Building zlib
|
|
Fortunately latest zlib versions come with CMake support making it much easier to build with Visual Studio.
|
|
1. Make sure you explicitly specify Release/Debug flavor `-DCMAKE_BUILD_TYPE=Release`
|
2. Build Shared version of zlib (i.e. dll) `-DBUILD_SHARED_LIBS=ON`
|
3. Use "NMake Makefiles" generator, default generator is multi version and much trickier to use.
|
|
|
Step by step:
|
|
Open Visual studio command prompt, for example `x64 Native Tools Command Prompt for VS 2017` or `x86 Native Tools Command Prompt for VS 2017` and change directory to location of zlib sources. Create build directory and run the commands:
|
|
For example for x64 release build
|
|
mkdir msvc-release-x64
|
cd msvc-release-x64
|
cmake -DBUILD_SHARED_LIBS=ON -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=c:\cppcms_deps\x64\Release ..
|
nmake
|
nmake install
|
cd ..
|
|
Debug
|
|
mkdir msvc-debug-x64
|
cd msvc-debug-x64
|
cmake -DBUILD_SHARED_LIBS=ON -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=c:\cppcms_deps\x64\Debug ..
|
nmake
|
nmake install
|
cd ..
|
|
|
### Checking the build.
|
|
After installation of PCRE and zlib you need to get structure like this:
|
|
c:\cppcms_deps\x64\Release
|
c:\cppcms_deps\x64\Release\include
|
c:\cppcms_deps\x64\Release\include\zlib.h
|
c:\cppcms_deps\x64\Release\include\pcre.h
|
...
|
c:\cppcms_deps\x64\Release\lib
|
c:\cppcms_deps\x64\Release\lib\zlib.lib
|
c:\cppcms_deps\x64\Release\lib\pcre.lib
|
...
|
c:\cppcms_deps\x64\Release\bin
|
c:\cppcms_deps\x64\Release\bin\zlib1.dll
|
c:\cppcms_deps\x64\Release\bin\pcre.dll
|
...
|
|
c:\cppcms_deps\x64\Debug
|
c:\cppcms_deps\x64\Debug\include
|
c:\cppcms_deps\x64\Debug\include\zlib.h
|
c:\cppcms_deps\x64\Debug\include\pcre.h
|
...
|
c:\cppcms_deps\x64\Debug\lib
|
c:\cppcms_deps\x64\Debug\lib\zlibd.lib
|
c:\cppcms_deps\x64\Debug\lib\pcred.lib
|
...
|
c:\cppcms_deps\x64\Debug\bin
|
c:\cppcms_deps\x64\Debug\bin\zlibd1.dll
|
c:\cppcms_deps\x64\Debug\bin\pcred.dll
|
|
## Building CppCMS
|
|
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DDISABLE_STATIC=ON -DCMAKE_INCLUDE_PATH=c:\Users\artik\msvc2017\x64\Debug\include -DCMAKE_LIBRARY_PATH=c:\Users\artik\msvc2017\x64\Debug\lib ..
|
SET PATH=%PATH%;c:\Users\artik\msvc2017\x64\Debug\bin;.\booster\
|
|
|
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DDISABLE_STATIC=ON -DCMAKE_INCLUDE_PATH=c:\Users\artik\msvc2017\x64\Release\include -DCMAKE_LIBRARY_PATH=c:\Users\artik\msvc2017\x64\Release\lib ..
|
SET PATH=%PATH%;c:\Users\artik\msvc2017\x64\Release\bin;.\booster\
|
|
|
## Optional Deps
|
|
OpenSSL
|
|
perl Configure VC-WIN64I --prefix=c:\Users\artik\msvc2017\x64\shared no-asm
|
http://developer.covenanteyes.com/building-openssl-for-visual-studio/
|
|
|
x64
|
|
perl Configure VC-WIN64A no-asm --prefix=c:\Users\artik\msvc2017\x64\Release --openssldir=c:\Users\artik\msvc2017\x64\Release
|
perl Configure debug-VC-WIN64A no-asm --prefix=c:\Users\artik\msvc2017\x64\Debug --openssldir=c:\Users\artik\msvc2017\x64\Debug
|
|
|
x86
|
|
perl Configure VC-WIN64A no-asm --prefix=c:\Users\artik\msvc2017\x64\Release --openssldir=c:\Users\artik\msvc2017\x86\Release
|
perl Configure debug-VC-WIN64A no-asm --prefix=c:\Users\artik\msvc2017\x64\Debug --openssldir=c:\Users\artik\msvc2017\x86\Debug
|
|
|
Precompiled ICU
|
|
https://www.npcglib.org/~stathis/blog/precompiled-icu/
|
|
BUIDING ICU:
|
|
https://wiki.qt.io/Compiling-ICU-with-MSVC
|
|
DOWNLOAD ZIP ONLY!!!
|
|
set PATH=%PATH%;c:\cygwin64\bin
|
dos2unix *
|
dos2unix -f configure
|
bash runConfigureICU Cygwin/MSVC --prefix=/cygdrive/c/Users/artik/msvc2017/x64/Release
|
make
|
make install
|
make distclean
|
move dlls from lib to bin
|
bash runConfigureICU --enable-debug --disable-release Cygwin/MSVC --prefix=/cygdrive/c/Users/artik/msvc2017/x64/Debug
|
make
|
make install
|
make distclean
|
move dlls from lib to bin
|
|
|