Category Archives: C++ Libraries

Print visual studio definitions at build-time.

Use the following code to check the values of common visual studio defines.

These defines are used inside Microsoft and other libraries. This macro can be used to print the values to the compiler output. For example, before and after certain header files are included.

#define _DEFINE_TO_STRING_(x) #x
#define _DEFINE_TO_STRING(x) _DEFINE_TO_STRING_(x)

#pragma message("_MSC_VER      is " _DEFINE_TO_STRING(_MSC_VER))
#pragma message("_MFC_VER      is " _DEFINE_TO_STRING(_MFC_VER))
#pragma message("_ATL_VER      is " _DEFINE_TO_STRING(_ATL_VER))
#pragma message("WINVER        is " _DEFINE_TO_STRING(WINVER))
#pragma message("_WIN32_WINNT  is " _DEFINE_TO_STRING(_WIN32_WINNT))
#pragma message("_WIN32_IE     is " _DEFINE_TO_STRING(_WIN32_IE))
#pragma message("NTDDI_VERSION is " _DEFINE_TO_STRING(NTDDI_VERSION)) 

// "Header file under investigation"
#include "stdafx.h"

#pragma message("_MSC_VER      is " _DEFINE_TO_STRING(_MSC_VER))
#pragma message("_MFC_VER      is " _DEFINE_TO_STRING(_MFC_VER))
#pragma message("_ATL_VER      is " _DEFINE_TO_STRING(_ATL_VER))
#pragma message("WINVER        is " _DEFINE_TO_STRING(WINVER))
#pragma message("_WIN32_WINNT  is " _DEFINE_TO_STRING(_WIN32_WINNT))
#pragma message("_WIN32_IE     is " _DEFINE_TO_STRING(_WIN32_IE))
#pragma message("NTDDI_VERSION is " _DEFINE_TO_STRING(NTDDI_VERSION)) 


Building Boost X for platform Y

How to build the Boost C++ library for different targets.

This is an example of building Boost 1.55 for Visual Studio 2017 (toolset v141)

  1. Run bootstrap.bat
  2. Edit project-config.jam
  3. Call b2.exe with the correct parameters
  1. Run bootstrap.bat

This should create the b2.exe executable that is the build manager for the Boost library.

2. Edit project-config.jam

Visual studio 2017 is MSVC 15 (https://dev.to/yumetodo/list-of-mscver-and-mscfullver-8nd)

import option ; 
 
using msvc : 14 : "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe";
 
option.set keep-going : false ; 

3. Call b2.exe with the correct parameters

Documentation for the B2 tool can be found here: https://boostorg.github.io/build/manual/master/index.html

The toolset is 14.1 (v141). And we want the libraries for x64.

> b2 toolset=msvc-14.1 address-model=64

We want static libraries (not dll):

> b2 toolset=msvc-14.1 address-model=64 link=static

We can specify to build Release or Debug versions:

> b2 toolset=msvc-14.1 address-model=64 link=static variant=release

With different build, it can be usefull to direct all output (created libraries) to a specific folder:

> b2 toolset=msvc-14.1 address-model=64 link=static variant=release --build-dir=.Output-x64-static-release