Learn the Open Source Library The first step is to compile and install the library, and then run a successful demo before you can do the work.
Let's talk about the installation of the Boost library under Linux.
[email protected] ~]$ TAR-ZXVF boost_1_55_0.tar.gz
[Email protected] boost_1_55_0]$. /bootstrap.sh--prefix=/home/mjf/lib
[Email protected] boost_1_55_0]$ sudo./b2 Install
1. Unzip
2. Generate Bjam
The above command can be provided with various options, specifically refer to the Help documentation:./bootstrap.sh--help. Where the--prefix parameter, you can specify the installation path, if not with the--prefix parameter, the default path is/usr/local/include and/usr/local/lib, respectively, storing the header files and various libraries.
3. Compiling, installing
This is all compiled. Of course, you can also choose to compile only one part, option--with-<library> only compile the specified library, such as input--with-regex only compile the Regex library.
Once the compilation is complete, install the header file and the generated library into the specified path (--prefix)
Some of the common parameters of Bjam are listed below:
| --build-dir=<builddir> |
The compiled temporary files will be placed in the BuildDir (this is a good management, you can delete it after compiling) |
| --stagedir=<stagedir> |
The path that holds the compiled library file, which is the default stage |
| --build-type=complete |
Compile all versions, or only a small subset of the versions will be compiled, exactly equivalent to: Variant=release, threading=multi;link=shared|static;runtime-link=shared |
| Variant=debug|release |
Decide what version to compile (Debug or release?) |
| Link=static|shared |
Decide whether to use a static library or a dynamic library |
| Threading=single|multi |
Decide whether to use single-threaded or multi-line libraries |
| Runtime-link=static|shared |
Decide whether to have a static or dynamic link C/S standard library |
| --with-<library> |
Compiles only the specified libraries, such as input--with-regex, and compiles only the Regex library. |
| --show-libraries |
Display the library names that need to be compiled |
when the installation is complete, we'll run an example:
#include <iostream> #include <boost/timer.hpp>using namespace Std;int main () {Boost::timer t;cout << " Max TimeSpan: "<<t.elapsed_max ()/3600<<" h "<<endl;cout << min tmiespan:" <<t.elapsed_ Min () << "s" <<endl;cout<< "now time Elapsed:" <<t.elapsed () << "S" <<endl;return 0;}
g++-o test test.cpp-i/home/mjf/lib/include-l/home/mjf/lib/lib
./test
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Boost.asio Study Note I. Installation of the Boost library under Linux