support of MSVC
名称 | VS版本 | Minimum version |
---|---|---|
msvc-11.0 | VS2012 | 1.52.0 |
msvc-12.0 | VS2013 | 1.55.0 |
msvc-14.0 | VS2015 | 1.59.0 |
msvc-14.1 | VS2017 | 1.64.0 |
msvc-14.2 | VS2019 | 1.71.0 |
msvc-14.3 | VS2022 | 1.78.0 |
Current Version(xyz): 1.86.0
1. 编译(x86)
x86 Native Tools Command Prompt for VS xxxx
as of Boost 1.47.0, the official name of the executable was changed to b2.
Gen b2 and build
cd C:\boost_x_y_z
bootstrap.bat
build
- VS2022
b2 stage --toolset=msvc-14.3 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="C:\boost\bin\vc143" link=static runtime-link=shared runtime-link=static threading=multi debug release
- VS2019
b2 stage --toolset=msvc-14.2
...
--stagedir="C:\boost\bin\vc142"
...
2. 使用
Copy the ‘C:\boost_x_y_z\boost’ folder to ‘C:’ disk
Project Properties
Project->Properties->Configuration Properties
头文件
VC++ Directories->General
- Additional Include Directories:
库链接
Linker->General
- Additional Library Directories:
Spectre mitigations in MSVC
vs2017/vs2019
- c/c++->Code Generation
Example - Creating and Managing Threads
#include <boost/thread.hpp>
#include <boost/chrono.hpp>
#include <iostream>
void wait(int seconds)
{
boost::this_thread::sleep_for(boost::chrono::seconds{ seconds });
}
void thread()
{
for (int i = 0; i < 5; ++i)
{
wait(1);
std::cout << i << std::endl;
}
}
int main()
{
boost::thread t{ thread };
t.join();
}
VS2015/13/12
The top of the reference header add:
#include "stdafx.h"