boost安装
windows下安装
Step1 下载
Step2 编译源代码
- 先把源代码放在D盘,eg:
D:\boost_1_59_0 - 在源代码中找到批处理bootstrap.bat,运行之后,源代码中新增了1个文件bjam.exe
Step3 VS中使用boost
测试文件代码:
#include <string>
#include <iostream>
#include <boost/shared_ptr.hpp>
class implementation
{
public:
~implementation() { std::cout <<"destroying implementation\n"; }
void do_something() { std::cout << "did something\n"; }
};
void test()
{
boost::shared_ptr<implementation> sp1(new implementation());
std::cout<<"The Sample now has "<<sp1.use_count()<<" references\n";
boost::shared_ptr<implementation> sp2 = sp1;
std::cout<<"The Sample now has "<<sp2.use_count()<<" references\n";
sp1.reset();
std::cout<<"After Reset sp1. The Sample now has "<<sp2.use_count()<<" references\n";
sp2.reset();
std::cout<<"After Reset sp2.\n";
}
void main()
{
test();
}
VS中使用boost还需要两步设置,即告诉编译器,boost的头文件在哪(添加 include 路径),库文件在哪(添加 library 路径),
- 在C++/general/Additional Include Directories选项下添加:
D:\boost_1_59_0 - 在linker/general/Additional Library Directories选项下添加:
D:\boost_1_59_0\stage\lib(这个是编译后产生的)
至此,完成windows下boost库在VS的配置了。
这篇博客详细介绍了在Windows下安装Boost库的步骤,包括从官方网站下载最新版本的源代码,编译源代码,以及在Visual Studio中配置包含路径和库路径,确保能够顺利使用Boost库。

3153

被折叠的 条评论
为什么被折叠?



