『boost』安装及使用的记录

来源:互联网 发布:.net编程用什么软件 编辑:程序博客网 时间:2024/06/05 12:07

原文链接:boost安装及使用的记录 

其他参考:windows下boost怎样安装与使用说明?

http://www.cnblogs.com/finallyliuyu/archive/2010/08/23/1806811.html

http://www.boostpro.com/download/

安装

ubuntu: 

1) 在新立得(Synaptic)里搜索boost安装即可。

2) 编译时候需要如果使用boost的lib文件,则需要用-l指明。

 

windows: 

1) 事先下载 icu,假设解压的路径是 c:\icu。

2) 在 boost主页下载安装包,解压,假设解压的路径是 c:\boost\。

3) 编译或下载bjam。

4) 安装方式有两种,一种是install,一种是stage。stage避免把文件拷贝一遍,推荐该方法。

 gcc

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" release --without-graph_parallel  --without-***

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" debug --without-graph_parallel  --without-***

(--without-*** 就是不要编译的库,比如--without-python --without-wave --without-mpi ,除此之外都编译)

或者

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" release --without-graph_parallel --with-***

bjam stage --toolset=gcc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\gcc" debug --without-graph_parallel --with-***

(--with-***就是仅编译的库,例如 --with-regex  --with-filesystem)

B msvc (打开Visual Studio 命令)

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" release --without-***

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" debug --without-***

或者

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" release --with-***

bjam stage --toolset=msvc -sICU_PATH="c:\icu" --stagedir="c:\boost\bin\vc10" debug --with-***

5) 在IDE中添加boost的库信息

vs 2010 IDE (每个项目都需要单独添加,很麻烦)

1.Include Path c:\boost  (root dir)
2.Library Path c:\boost\bin\vc10\lib  (lib dir)
3.Source Path c:\boost\boost  (include-file dir)

CodeBlocks
1.Linker
  Setting -> Compiler and debuger -> Global compiler setting -> Linker setting ->
      Add  (c:\boost \bin\gcc\*.a) (all the lib files)
2.Search
  Setting -> Compiler and debuger -> Global compiler setting -> Search directories -> Compiler ->
      Add (c:\boost)  (root dir)

6) 如果是命令行编译,可以改如下的bat文件

A gcc

set boost_root=c:\boost
set boost_lib=%boost_root%\bin\gcc\lib
set use_boost=-I %boost_root% -L %boost_lib%
set filesystem=-lboost_filesystem-mgw44-mt-d-1_46_1 -lboost_system-mgw44-mt-d-1_46_1
set regex=-lboost_regex-mgw44-mt-d-1_46_1

:: example
:: g++ lex.cpp -o lex %use_boost%
:: g++ regex_1.cpp -o regex_1 %use_boost% %regex%
:: g++ traverse_dir.cpp -o traverse_dir_gcc_new %use_boost% %filesystem%

 msvc

set boost_root=c:\boost
set boost_lib=%boost_root%\bin\vc10\lib
set use_boost=/EHsc /I %boost_root% /MD /link /libpath:%boost_lib%

:: example
:: cl regex_1.cpp /Feregex_1_vc.exe %use_boost%
:: del regex_1.obj

当然,也可以写一个makefile。


boost里面的库简单介绍


原创粉丝点击