How to Install boost on Ubuntu?
I'm on Ubuntu, and I want to install Boost. I tried with
sudo apt-get install boost
But there was no such package. What is the best way to install boost on Ubuntu?
You can use apt-get
command (requires sudo
)
sudo apt-get install libboost-all-dev
Or you can call
aptitude search boost
find packages you need and install them using the apt-get
command.
Get the version of Boost that you require. This is for 1.55 but feel free to change or manually download yourself:
wget -O boost_1_55_0.tar.gz https://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.gz/download
tar xzvf boost_1_55_0.tar.gz
cd boost_1_55_0/
Get the required libraries, main ones are icu
for boost::regex
support:
sudo apt-get update
sudo apt-get install build-essential g++ python-dev autotools-dev libicu-dev build-essential libbz2-dev libboost-all-dev
Boost's bootstrap setup:
./bootstrap.sh --prefix=/usr/
Then build it with:
./b2
and eventually install it:
sudo ./b2 install
Installing Boost on Ubuntu with an example of using boost array:
Install libboost-all-dev and aptitude
sudo apt-get install libboost-all-dev
sudo apt-get install aptitude
aptitude search boost
Then paste this into a C++ file called main.cpp:
#include <iostream>
#include <boost/array.hpp>
using namespace std;
int main(){
boost::array<int, 4> arr = {{1,2,3,4}};
cout << "hi" << arr[0];
return 0;
}
Compile like this:
g++ -o s main.cpp
Run it like this:
./s
Program prints:
hi1
链接地址: http://www.djcxy.com/p/51054.html
上一篇: 提升的向量
下一篇: 如何在Ubuntu上安装boost?