Main  /  Edit version 4  /  Edit version 5  /   /  Users Area

Difference "Building CppCMS using Visual Studio" ver. 4 versus ver. 5

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.
## 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

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