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
- 开始菜单启动Visual Studio 2015的vs2015 开发人员命令行提示,然后转到boost根文件夹,运行bootstrap.bat生成b2.exe。
- 运行命令: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