---
title: "ubuntu下Boost库安装"
author: "dongtianzhe"
date: "2010-12-03T17:04:33Z"
tags: []
categories: ["编程语言"]
slug: "ubuntu-boost"
draft: false
lastmod: "2010-12-03T17:05:30Z"
id: 832822
url: "https://silverbullet1985.iteye.com/blog/832822"
---

最近在研究hadoop和云计算，但是hadoop是java写的，在hadoop上编写程序也要用java，所以最近可能会经常使用java。为了防止忘记C++，今天决定开始研究一下boost库。

先把boost装到ubuntu吧。

下载boost_1_43_0.tar.gz到/home/dtz/下，解压 tar zxvf boost_1_43_0.tar.gz
cd boost_1_43_0,

执行：

sudo ./bootstrap.sh  

sudo ./bjam install

这样boost库就安装好了，下面编写一个例子测试一下：

```java
#include <iostream>
#include <boost/scoped_ptr.hpp>

using namespace std;

int main(int argc, char *argv[]) {
    boost::scoped_ptr<int> i(new int);
    *i = 2;
    
    cout << *i << endl;

    return 0;
}

```


在shell中编译执行：

![](http://dl.iteye.com/upload/attachment/359962/5ae83a03-4f61-3bb3-953e-f3868ca65774.png)