Boost. asio Study Notes 1. Installation of the boost library in linux, boost. asioboost

Source: Internet
Author: User

Boost. asio Study Notes 1. Installation of the boost library in linux, boost. asioboost

You are welcome to reprint it. Please enter the original address for reprinting.: Http://blog.csdn.net/majianfei1023/article/details/46761029


The first step to learn about open-source libraries is to compile and install the libraries, and then run a demo to complete subsequent work.

The following describes how to install the boost library in linux.

[Mjf @ localhost ~] $Tar-zxvf boost_1_55_0.tar.gz
[Mjf @ localhost boost_000055_0] $./Bootstrap. sh -- prefix =/home/mjf/lib
[Mjf @ localhost boost_000055_0] $Sudo./b2 install


1. Extract


2. Generate bjam

The preceding command can have various options. For more information, see./bootstrap. sh -- help. The -- prefix parameter specifies the installation path. If the -- prefix parameter is not included, the default path is/usr/local/include and/usr/local/lib, store header files and various libraries respectively.


3. Compile and install
Here is all compilation. Of course, you can also choose to compile only a part. The option -- with-<library> is used to compile only the specified library. For example, if you enter -- with-regex, only the regex library is compiled.
After the compilation is complete, install the header file and the generated library in the specified path (-- prefix ).

Some common parameters of bjam are listed as follows:

-- Build-dir = <builddir> The compiled temporary file will be placed in builddir (this is better managed and can be deleted after compilation)
-- Stagedir = <stagedir> Path for storing compiled library files. The default path is stage.
-- Build-type = complete

Compile all the versions. Otherwise, only a small part of the versions will be compiled, which is equivalent:

Variant = release, threading = multi; link = shared | static; runtime-link = shared

Variant = debug | release Determine the version to compile (Debug or Release ?)
Link = static | shared Decide whether to use static or dynamic Databases
Threading = single | multi Decide whether to use a single thread or multi-thread Library
Runtime-link = static | shared Determines whether the database is static or dynamically linked to the C/C ++ standard library.
-- With-<library> Compile only the specified database, for example, input -- with-regex to compile only the regex database.
-- Show-libraries Display the name of the library to be compiled


After the installation is complete, let's 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. cpp-I/home/mjf/lib/include-L/home/mjf/lib

./Test




Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.