C + + library boost installation

Source: Internet
Author: User

Http://blog.chinaunix.net/uid-12226757-id-3427282.html

Ubuntu

Apt-get Install Libboost-dev

All:

apt-get install libboost-all-dev

Look at some of the information written:
Apt-get install Libboost-dev libboost-dbg libboost-doc bcp libboost-*

If you are not prompted enough, add sudo or switch to an account with sufficient privileges to install!

Linux itself with STL, is SGI version, can be used directly, without installation.

Build Your own installation:

Download ziphttp://www.boost.org/

首先要编译生成boost安装工具bjam
进入boost目录执行:
./bootstrap.sh

Output:

[Email protected]:~/download/boost_1_57/boost_1_57_0#./bootstrap.sh
Building Boost.build engine with toolset gcc ... tools/build/src/engine/bin.linuxx86/b2
Detecting Python Version ... 2.7
Detecting Python root .../usr
UNICODE/ICU support for Boost.regex?... not found.
Generating boost.build configuration in Project-config.jam ...

Bootstrapping is done. To build, run:

./b2

To adjust configuration, edit ' Project-config.jam '.
Further information:

-Command line help:
./B2--help

-Getting started Guide:
Http://www.boost.org/more/getting_started/unix-variants.html

-Boost.build Documentation:
Http://www.boost.org/boost-build2/doc/html/index.html

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 (recommended), 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. Note that boost 1.49 will generate two files Bjam and B2 in the current directory, both of which are the same, so the next steps can be performed with either of these two.

usingmpi ;  #如果需要MPI功能,需要在 /tools/build/v2/user-config.jam 文件的末尾添加

The next step is to compile the source code with the generated Bjam script.

./b2 -a -sHAVE_ICU=1  #-a参数,代表重新编译,-sHAVE_ICU=1代表支持Unicode/ICU

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. boost1.49 full compilation, in the author intel®core™2 Duo CPU T5750 @ 2.00ghzx2, 2G DDR2 memory on the old machine, using the above options, half an hour is almost. This is a time to bear. All compiled and installed, psychologically feel comfortable. ^_^

My steps:

./bootstrap.sh --prefix=/usr

一个漫长的过程。

Once the compilation is complete, install the header file and the generated library into the specified path (--prefix)

./b2 install

Test:

#include <iostream>#include<boost/bind.hpp>using namespacestd;using namespaceboost;intFunintXintY) {returnx+y;}intMain () {intm=1;intn=2; cout<<boost::bind (fun,_1,_2) (m,n) <<Endl; return 0;}

Installation of the Boost library under Linux     recently, the library was installed because a program was compiled using the C + + boost library. However, some minor problems have been encountered. So record it for the reference of others.           First talk about my environment: Ubuntu 12.04 32bit, &NBSP;GCC 4.6.3          actually in Ubuntu , you can use the command to install sudo apt-get installs libboost-dev           However, after I install this, there are many errors in compiling the program. And it's all a system file error. I started to think it was my boost library version was wrong, and later changed several versions, the same problem occurred. Later, I compiled a boost.1.42. Then the program passed smoothly. I thought about it later, probably because the boost from the above command was installed by default and did not turn on MPI when compiling the package. And my program needs this feature. Here are the brief steps for the installation (I compiled the boost1.42 and boost1.50, both of which are installed in the same way, for example):  www.2cto.com   1. Download boost1.53 source files (93.56M)  http://sourceforge.net/projects/boost/files/latest/download?source=dlp 2. After decompression, enter the Boost_1_53_0 directory, execute:. Bootstrap.sh 3. (emphasis) Modify the  tools/build/v2/user-config.jam file, with the following line "using MPI;" (Note that there is a space behind MPI,       then a semicolon)   4. Execution: ./b2  5. Execute: sudo./b2  install      The above is all the installation process, because the online mentioned more, so here withheld. The point is to mention the third step, be sure to remember. However, it doesn't matter if your program doesn't need the MPI feature. Apply the default settings. And, fourth step, you can do it at the back home PrefiThe x parameter, if not added, is installed after the default header file in the/usr/local/include/boost directory. The library file is in the/usr/local/lib/directory. Not modified by default.         If a library file cannot be loaded at run time when the program is compiled, the/usr/local/lib of all boost library files under the/usr/lib directory will be available.  http://blog.chinaunix.net/uid-12226757-id-3427282.htmlhttp://www.cnblogs.com/longcpp/archive/2012/06/06/ 2538251.htmlhttp://blog.csdn.net/dotphoenix/article/details/8459277

C + + library boost installation

Related Article

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.