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
#include "Boost_Signal_Learning.h" #include <iostream> #include "boost/signals.hpp" void my_first_slot() { std::cout << "void my_first_slot()/n";} class my_second_slot { public: void operator()() const { std::cout << "void my_second_slot::operator()() const/n"; } }; int main() { boost::signal<void ()> sig; sig.connect(&my_first_slot); sig.connect(my_second_slot()); std::cout << "Emitting a signal.../n"; sig(); }

 

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

 

 

你可能感兴趣的:(serialization,System,regex,Path,include,Signal)