boost裁剪和编译

winddows:

bjam --show-libraries 查询所有的模块

1、运行bootstrap.bat编译bjam。

2、bjam.exe ./tools/bcp

3、在bin.v2/tools/bcp/目录下可以找到 bcp.exe。这就是我们所需要的程序了。

假设我们允许程序员用A、B、C、D这样四个模块,那么可以这样:

bcp --boost:<boost-root-directory> A B C D <output-directory>

这里A、B、C、D可以是:

Boost的头文件名。如: boost/shared_ptr.hpp

Boost的库名。如:regex

Boost的头文件标题:boost/shared_ptr 或者 shared_ptr

如果是在boost根目录下,那指定boost目录的参数也可以省去。

linux:

1、 执行 ./bootstrap.sh生成bjam
2、 生成bcp程序 ./bjam tools/bcp/
3、 查看是否生成了bcp: cd dist/bin
4、 回到boost根目录下开始提取。
5、 在根目录下创建一个目录,用于存放提取的文件 mkdir boostlite
6、 ./dist/bin/bcp XXX boostlite/

windows下编译BOOST

  1. 开始菜单启动Visual Studio 2015的vs2015 开发人员命令行提示,然后转到boost根文件夹,运行bootstrap.bat生成b2.exe。
  2. 运行命令:b2 stage --toolset=msvc --without-coroutine --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --without-test link=static runtime-link=static threading=multi address-model=64 debug release

(1)可以设置为仅用于当前project:

选中当前project->Properties->Configuration Properties->C/C++->General: Additional Include Directories: 设置 

选中当前project->Properties->Configuration Properties->Linker->General: Additional LibraryDirectories: 设置

(2)可设置为仅用于当前Solution:

选中当前project->Properties->Configuration Properties->VC++ Directories:

Include Directories: 设置 LibraryDirectories: 设置 

(3)可设置为OS当前用户下的VC++环境(当前用户下VC++所创建的所有Solution)

在某个已打开的工程下,切换到Property Manager 选项卡,然后然后展开当前工程的properties配置,打开Microsoft.Cpp.Win32.User

选择Common Properties->VC++ Directories:

Include Directories: 设置  LibraryDirectories: 设置

(4)可设置为OS所有用户下的VC++环境

可以编辑 Microsoft.Cpp.Default.props 、Microsoft.Cpp.props 。这里就不介绍了。

Linux下编译:

./bootstrap.sh 

./b2 --show-libraries

./b2 stage --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --without-test link=static runtime-link=static threading=multi address-model=64 architecture=x86 variant=debug,release

./b2 install --prefix=/usr/local --toolset=gcc --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --without-test link=static runtime-link=static threading=multi address-model=64 architecture=x86

echo "/usr/local/lib/" >> /etc/ld.so.conf
ldconfig

g++ -lz -lpthread test.c -lboost_filesystem -lboost_thread



  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值