编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

时间:2023-03-09 21:55:31
编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

首先下载得到boost的最新版(目前最新版是1.63)

下载地址:
编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

也可以从这里直接下载

http://download.csdn.net/detail/zengraoli/9815337

下载完成后解压出来

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

编译32位的boost库

打开vs的32位命令行工具

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

进入到boost源代码文件夹中

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

进入到boost源代码文件夹中

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

运行bootstrap.bat

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

执行如下操作,对boost进行编译

(msvc版本14.0对应的是vs2015,--stagedir是指定编译后存放的目录,文章附录有vs版本对应编号)

bjam stage --toolset=msvc-14.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14" link=static runtime-link=shared runtime-link=static threading=multi debug release

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

这样得到的是就是32位的boot库

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

编译64位的boost库

打开vs的64位命令行工具

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

进入到boost源代码文件夹中

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

运行bootstrap.bat

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

执行如下操作,对boost进行编译

(msvc版本14.0对应的是vs2015,--stagedir是指定编译后存放的目录)

bjam stage --toolset=msvc-14.0 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

这样得到的是就是64位的boot库

开始使用boost

设置测试的程序为64位

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

设置附加的包含路径(下载之后解压的boost文件夹):

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

设定库路径:

编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

然后建立第一个boost项目,代码如下:

  1. #include "boost/thread.hpp"
  2. #include "iostream"
  3. using namespace std;
  4. void mythread()
  5. {
  6. cout << " hello,thread! " << endl;
  7. }
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10. boost::function<void()> f(mythread);
  11. boost::thread t(f);
  12. t.join();
  13. cout << " thread is over! " << endl;
  14. return 0;
  15. }
得到输出
编译并使用boost库(win7+boost1.63+vs2015+32位or 64位),超详细,boost于vs2017下编译(64/32bit)

附录

附上版本对应编号

  1. VC6
  2. VC7(2003)
  3. VC8(2005)
  4. VC9(2008)
  5. VC10(2010)
  6. VC11(2012)
  7. VC12(2013)

https://blog.csdn.net/zengraoli/article/details/70187556

一个boost线程池的例子

附带一个boost使用线程池的例子

http://blog.csdn.net/zengraoli/article/details/70187693

下面文章是vs2015编译, 将140换为141,则可以编译给vs2017用.
编译64位:
先打开vs2017 64位环境的cmd环境, 进入boost源目录, 运行bootstrap.bat,然后运行下面编译命令,
stagedir用来指定库存放的位置
bjam stage --toolset=msvc-14.1 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release

编译32位:

先打开vs2017 x86环境的cmd环境, 进入boost源目录, 运行bootstrap.bat,然后运行下面编译命令,
bjam stage --toolset=msvc-14.1 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x86" link=static runtime-link=shared runtime-link=static threading=multi debug release

要等好一会儿的.

https://blog.csdn.net/rocklee/article/details/72885587