1. Dependent installation
apt-get install mpi-default-dev libicu-dev python-dev python3-dev libbz2-dev zlib1g-dev
2. Visit the boost official website to download the latest version of boost
3. Unzip the downloaded file, for example, the downloaded file is under ~/Downloads
cd ~/Downloads
./bootstrap.sh
Generated files b2 and bjam calculate md5sum and find that they are consistent. To
generate bjam, the above command can have various options. For details, please refer to the help document: ./bootstrap.sh --help. The –prefix parameter can specify the installation path. If the –prefix parameter is not included (recommended), the default paths are /usr/local/include and /usr/local/lib, which store header files and various libraries respectively. After the execution is complete, bjam will be generated, and existing scripts will be automatically backed up. Note that boost 1.49 will generate two files bjam and b2 in the current directory, these two are the same,
5. Compile and install boost
After the compilation is complete, install it, that is, put the header file and the generated library in the specified path (--prefix)
./b2 //Compile boost
sudo ./b2 install //Install the generated library to the /usr/local/lib directory, and the default header file is under the /usr/local/include/boost directory.
6. Uninstall
Just delete the files in the /usr/local/lib and /usr/local/include/boost directories.
7. Test if the installation is correct
Create a new cpp file
vim boot.cpp
#include <string> #include <iostream> #include <boost/version.hpp> #include <boost/timer.hpp> using namespace std; intmain() { boost::timer t; cout << "max timespan: " << t.elapsed_max() / 3600 << "h" << endl; cout << "min timespan: " << t.elapsed_min() << "s" << endl; cout << "now time elapsed: " << t.elapsed() << "s" << endl; cout << "boost version" << BOOST_VERSION <<endl; cout << "boost lib version" << BOOST_LIB_VERSION <<endl; return 0; }compile
g++ boot.cpp -o boot
./bootAfter successful compilation, the result will be displayed, and the last two lines will print the boost version
max timespan: 2.56205e+09h min timespan: 1e-06s now time elapsed: 0.000121s boost version106300 boost lib version1_63