Main  /  Edit version 8  /  Edit version 9  /   /  Users Area

Difference "Building CppCMS using Visual Studio" ver. 8 versus ver. 9

Content:

<!--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.
## Before we begin: Basic Build 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.
Checks: open cmd and try to run cmake, python and optionally git - see if it works.
And finally make sure the directories you are building in are not scanned by anti-virus - otherwise you may get some build failures - due to files being locked by AV.
### 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. Use "NMake Makefiles" generator, default generator is multi flavor one and much harder to use properly.
2. Make sure you **explicitly** specify Release/Debug flavor `-DCMAKE_BUILD_TYPE=Release`
3. Build Shared version of PCRE (i.e. dll) `-DBUILD_SHARED_LIBS=ON`
4. Make sure you put `-DPCRE_SUPPORT_UNICODE_PROPERTIES=ON` option on to enable utf-8 support - otherwise regex tests will fail
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 build:
Release:
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. Use "NMake Makefiles" generator, default generator is multi version and much trickier to use.
2. 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`
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 build
Release
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 results.
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
Note - the DLLs and libs with "d" suffix are placed in debug location.
## Optional Dependencies
### OpenSSL
*Warning:* OpenSSL does not mangle its Debug and Release flavors - so make sure you have a separate install prefix for two OpenSSL flavors and never mix them!
First of all you need to install perl as it is basic building and configuration tool. ActivePerl is recommended. Note: msys2 perl or cygwin perl does not work.
First of all you need to install perl as it is basic building and configuration tool. ActivePerl is recommended. Make sure it is in system path. Note: msys2 perl or cygwin perl does not work.
Note: Make sure you
perl Configure VC-WIN64I --prefix=c:\Users\artik\msvc2017\x64\shared no-asm
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
BUIDING ICU:
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
## 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\
## References
1. <http://developer.covenanteyes.com/building-openssl-for-visual-studio/>
2. <https://wiki.qt.io/Compiling-ICU-with-MSVC>
3. <https://www.npcglib.org/~stathis/blog/precompiled-icu/>

About

CppCMS is a web development framework for performance demanding applications.

Support This Project

SourceForge.net Logo

Поддержать проект

CppCMS needs You


Navigation

Main Page


Valid CSS | Valid XHTML 1.0