Boost 安装及简单使用

Building of Boost:

1. Down load boost, bjam from http://www.boost.org/
2. Execute Build.bat in bjam folder to get bjam.exe
3. copy bjam.exe to the same folder as boost-build.jam (under folder "/Boost/boost_1_42_0/boost_1_42_0" in my version).
4. Open vs2009 command prompt and then execute "bjam stage --toolset=msvc-9.0 --without-python --stagedir="D:/Boost/boost_1_42_0/boost_1_42_0" link=shared runtime-link=shared threading=multi debug release". this link is to explain this command. http://tech.ddvip.com/2009-05/1242887529120322.html

 

 

Simple Using:

1. Seting additional include path to be "D:/Boost/boost_1_42_0/boost_1_42_0/".
3. Add "D:/Boost/boost_1_42_0/boost_1_42_0/lib/" to the lib dir.
4. Add "D:/Boost/boost_1_42_0/boost_1_42_0/lib/" to the system env variable "path"
5. write this line into header file to specify dynamic link. #define BOOST_DYN_LINK. Boost is using static link as default.
6. write following code to using boost::signals

 

Boost 大多数功能都是不需要编译就可以使用了, 使用 bjam.exe --show-libraries 命令可以打印出需要编译出库才能使用的模块:

The following libraries require building:
    - date_time
    - filesystem
    - function_types
    - graph
    - iostreams
    - math
    - mpi
    - program_options
    - python
    - regex
    - serialization
    - signals
    - system
    - test
    - thread
    - wave

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Boost库的使用案例可以通过以下步骤进行: 1. 下载和安装Boost库:首先,你需要从Boost官方网站下载并解压Boost库的压缩包[1]。然后,进入解压后的目录,并执行bootstrap.sh脚本来配置Boost库的编译选项[3]。最后,使用b2命令编译并安装Boost库[3]。 2. 包含头文件:大多数Boost库只需要在你的源代码中包含相应的头文件即可[2]。例如,如果你想使用boost::tribool库,只需要在你的C源文件中添加以下include语句: ```cpp #include <boost/XXX.hpp> #include <boost/logic/tribool.hpp> //使用tribool库 ``` 3. 使用Boost库:一旦你包含了所需的头文件,你就可以使用Boost库提供的功能了。你可以根据你的需求使用不同的Boost库组件,比如算法库、时间处理库、异步并发库等[1]。 下面是一个使用Boost库的简单示例,展示了如何使用boost::tribool库来处理三态逻辑值: ```cpp #include <iostream> #include <boost/logic/tribool.hpp> int main() { boost::logic::tribool value = boost::logic::indeterminate; // 初始化为不确定状态 if (value) { std::cout << "Value is true" << std::endl; } else if (!value) { std::cout << "Value is false" << std::endl; } else { std::cout << "Value is indeterminate" << std::endl; } return 0; } ``` 在这个示例中,我们使用boost::logic::tribool库来定义一个三态逻辑值。我们将其初始化为不确定状态,并根据其值输出相应的信息。 希望这个示例能帮助你理解如何使用Boost库。你可以根据自己的需求选择合适的Boost库组件,并在你的代码中包含相应的头文件来使用它们[1][2]。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值