The first step in learning the open Source Library is to compile the installation, and then we can write a demo to test.
So in this chapter we learn to install the boost library in Linux and install the full library directly for your convenience.
The version I'm using is Boost_1_55_0, and the version is very different.
[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
To generate the 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. Once executed, Bjam will be generated and the existing script will be automatically backed up.
3. Compiling, installing
Note that 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.
Install, that is, the header file and the generated library, placed under 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 |
All ready, take an example to test:
#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
It's done
!
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