How to configure boost in ubuntu

Source: Internet
Author: User

Boost version: boost_000052_0
Ubuntu: ubuntu-12.04.1-desktop-i386

There are two installation methods:

==================
First:

It is also the simplest: Enter
# Apt-cache search boost
You will see a lot of file information, and you will see a file called libboost-dev, you can directly install this file:
# Apt-get install libboost-dev
The installation is successful. This speed is very fast because the lib file is directly copied to the system.
You can use the final code in this article to test whether the installation is successful or not.

====================
Second:
This is slow because you need to compile the lib library by yourself.
First download the boost library from the website www.boost.org to download the linux boost library in two formats: 1). bz2 2). gz
I ended with gz. Put it in the linux File System. Assume It is/usr/local/boost_1_52_0.tar.gz.

Step 1: Decompress the compressed package. The command is as follows (# is used only as the starting flag and is ignored when you press the command ):
# Cd/usr/local/
# Tar-zxvf boost_000052_0.tar.gz

Step 2: Decompress the package and obtain the folder boost_000052_0. Run the following command:
# Cd boost_000052_0/
#./Bootstrap. sh // This command is similar to configuring the environment

Step 3: run the two-step command to get a file named bjam. Run this file:
#./Bjam // it may take a dozen minutes to complete the installation.

Step 4: Check whether the installation is successful: Create test. cpp in any directory in linux

# Include <iostream>
# Include <boost/lexical_cast.hpp>

// Using namespace std;

// Using namespace boost;
Int main ()
{
Int a = boost: lexical_cast <int> ("123456 ");
Std: cout <a <std: endl;
Return 0;
}

This is a simple program for converting strings into integers.

Run the following command:
# G ++ test. cpp-o test
#./Test

The output result is 123456.
It means that boost is successfully installed, so you can enjoy boost !!!

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.