1.gcc版本>3.2html
2.Yum 的 boost 和boost-python文件很小,好像不行。因此编译安装。python
3.boost库分为三种:无需编译;单独编译;部分编译。python须要单独编译。ios
4.使用无需编译库的一个例子:c++
include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> int main() { using namespace boost::lambda; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " ); }
Copy the text of this program into a file called example.cpp. Now, in the directory where you saved example.cpp, issue the following command:bootstrap
c++ -I path/to/boost_1_54_0 example.cpp -o example
To test the result, type:多线程
echo 1 2 3 | ./example
5.编译中有warning没有关系,但不能有error.测试
6.安装单独编译子库。注意,工做目录。工做目录决定了b2 install的安装内容。ui
$ cd path/to/boost_1_54_0 $ ./bootstrap.sh --help 查看配置选项
7.安装定制库this
试运行一个例子,会产生可执行代码。Copy
to a different directory, then change to that directory and run:spaPREFIX
/share/boost-build/examples/hello
PREFIX
/bin/b2PREFIX
b2 --build-dir=build-directorytoolset=toolset-name stage 好比:
$ cd ~/boost_1_54_0 $ b2 --build-dir=/tmp/build-boost toolset=gcc stage :会产生一个静态共享非调试多线程的boost库。若是想要产生全部类型的boost库,使用built-type=complete。 statge目标会将库二进制文件放在stage/lib中,能够使用stage-dir=...指定。查看帮助 b2 --help.为了限制时间能够:
8.一个用Link例子。
9.编译好的库的命名规则。xxx.a xxx.so.
10.若是你的程序Link到了一个库,那么运行的时候,须要设定好环境变量,以便可以在运行时找到动态库。LD_LIBRARY_PATH。
$ VARIABLE_NAME=path/to/lib/directory:${VARIABLE_NAME} $ export VARIABLE_NAME