Complete steps for installing the boost library under linux

  • 2020-12-13 19:16:18
  • OfStack

preface

The Boost library is a portable source code C++ library. As a backup to the standard library, it is one of the development engines of the C++ standardization process. The Boost library was initiated by members of the C++ Standards Committee Library Working Group, and some of its contents are expected to become the C++ standard library content of the next generation. The C++ community is very influential, and is a "quasi" standard library. Boost, due to its emphasis on cross-platform and the emphasis on the standard C++, has nothing to do with writing platforms.

The installation process of linux is as follows:

To the official website to download the latest: http: / / sourceforge net/projects/boost/files/boost / 1.47.0 / or www. boost. org

1. The easiest way:


apt-cache search boost

Search all boost libraries

And then:


sudo apt-get install libboost-all-dev

Install the appropriate libraries

2. Compile and install,

You need to go to the official website to download the latest version, which has reached 1.47.0

1. Download and unzip to /opt/boost_1_47_0

2. Resolve dependencies sudo apt-get install python-dev gccxml

If it is not complete, use ES61en-ES62en depends XXXXXXX

3. Compile bjam:


 #cd /opt/boost_1_47_0
 #sudo ./bootstrap.sh

Compile successfully

4. Compile boost


 #sudo ./bjam

Begin to compile

It takes about ten minutes

After compiling:


The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
 /home/terry/Local/boost_1_47_0
The following directory should be added to linker library paths:
 /home/terry/Local/boost_1_47_0/stage/lib

Because I am into/home terry Local/boost_1_46_1

So when it's compiled, it looks like this

5.update Dynamic Link Library:


sudo ldconfig

installed

3. Test use:

1. Test code


#cat test.cpp 
#include <boost/lexical_cast.hpp>
#include <iostream>

int main()
{
 using boost::lexical_cast;
 int a= lexical_cast<int>("123456");
 double b = lexical_cast<double>("123.456");
 std::cout << a << std::endl;
 std::cout << b << std::endl;
 return 0;
}

2. Compile and run


--g++ -o test test.cpp
#ls
test test.cpp
# ./test 
123456
123.456

Conclusion:


Related articles: