If it's a new machine and there's no boost, then a direct command
sudo apt-get install Libboost-all-dev
Header files are generally installed in
/usr/include
Below is a directory boost, which is a header file. And the library files are usually placed in
/usr/lib/x86_64-linux-gnu
Directory. such as the Libboost_system.a file.
How to view the current installed boost version
Dpkg-s/USR/INCLUDE/BOOST/VERSION.HPP
With the above command, you will be able to find the boost version, and the results may look like this:
Libboost1. 54-dev:/usr/include/boost/version.hpp
Two how to remove the current installed boost
sudo apt-get autoremove libboost1. 54-dev
Then you can remove the boost. The Libboost1.54-dev above is the version you saw in the first step.
Note that if you are using the following command to install the boost
sudo apt-get install Libboost-dev
Then very likely, in the directory/usr/lib/x86_64-linux-gnu there is no LIBBOOST_SYSTEM.A and other files, this is to pay attention to.
Three how to install the old version of boost:
1 Download the old version, mine is the download 1.55, corresponding to the version path:
https://sourceforge.net/projects/boost/files/boost/1.55.0/
2 Execute under the root directory:
./bootstrap.sh--with-toolset=clang
3 Execution:
./b2 Install --build-type=complete --layout=versioned threading=multi --prefix="/usr/lib/ boost-1.55 "
After the compilation is complete, use:
4 Setting environment variables
Take the boost library's storage directory/usr/boost as an example, open/etc/profile and append the following (the first two behaviors compile-time paths):
Export Cplus_include_path=/usr/boost/include: $CPLUS _include_path
Export Library_path=/usr/boost/lib: $LIBRARY _path
Export Ld_library_path=/usr/boost/lib: $LD _library_path
Finally, execute the command to make the environment variable effective:
# Source/etc/profile
5 test results:
New File Boost_test.cpp
#include <string> #include <iostream> #include <boost/version.hpp> #include <boost/timer.hpp> using namespace std; int main()
{
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;
}
Compilation: g++ Boost_test.cpp-o boost_test
Popular science for four boost libraries:
The boost library is a generic term for some C + + libraries that provide extensions for the C + + language standard library. Boost Library is developed and maintained by the Boost community organization. Its purpose is to provide C + + programmers with free, peer-reviewed, portable libraries. The Boost library works perfectly with the C + + standard library and provides extended functionality. The Boost library is licensed using boost license, and commercial non-commercial use is permitted and encouraged under this agreement. One of the aims of the boost community is to provide a reference for the standardization of C + +, and the promoter of the boost community, Dawes, is one of the members of the C + + standards committee. In the development of the boost library, the boost community has also achieved fruitful results in this direction. In the TR1 of the C + + standard library for approval, there are 10 boost libraries as candidates for the standard library. In the updated TR2, there are more boost libraries to be added to them. In a sense, the boost library becomes a quasi-standard library with practical significance. Most of the boost library features need to include only the corresponding header files, and a few (such as regular expression libraries, file system libraries, etc.) require a link library. There are many libraries with industrial strength, such as graph library. Many of the library functions in boost are an extension of the language function, which is constructed in a sophisticated manner and does not take time to study. The other side of boost, such as graph, is an industrial-strength, well-structured, high-quality code that is worth reading, and can be used with confidence in the product code.
Change boost version under Ubuntu 16.04