- 安装 Visual Studio 2012.
- 安装更新 Visual Studio 2012..
- 下载 Boost from SourceForge.
- 解压 boost
- 用管理员权限运visual Studio 2012 tools Commands,
开始..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt
. - 用命令切换到boost所在目录
cd c:\boost153
. - 运行
bootstrap.bat
. - 运行
bjam.exe
. 构建所有库,忽略所有警告 -
编译完成时会提示如下内容(可能要花好长时间,随电脑配置而定):
The Boost C++ Libraries were successfully built! The following directory should be added to compiler include paths: C:/boost153 The following directory should be added to linker library paths: C:\boost153\stage\lib
-
接下来在Visual Studio 里加入路径.
- 创建C++ project.
- 在建Project之前, 添加
C:/boost153
到
compiler include path
和C:\boost153\stage\lib
到linker library path
. - 选择Visual Studio
Properties
, 选择tConfiguration Properties..VC++ Directories
. -
写一个demo:
// Source code below copied from: // http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html #include "stdafx.h" #include <string> #include <iostream> #include <conio.h> // Supports _getch() #include <boost/foreach.hpp> int main() { std::string hello( "Hello, world!" ); BOOST_FOREACH( char ch, hello ) { std::cout << ch; } _getch(); return 0; }
-
运行结果:
Hello, world!
vs2012 编译boost
最新推荐文章于 2021-05-11 13:20:10 发布