Awesome Hacks!

プログラミング初心者なので地道に勉強していきます。分からない人の立場から整理していきます。

C++_boost::shared_ptrを使うための前準備(Boostライブラリのインストールとビルド)

boost/shared_ptrを使うには?

1. boost::weak_ptrを利用するケース|オブジェクトの広場
Let's Boost - インストール方法

 
Boostライブラリのダウンロードが必要。
詳細は上記サイトを参照。


 
スムースに行かなかったので、自分なりの補足を。。。
 
Let's Boost - インストール方法
上記サイトのアーカイブをダウンロード
f:id:tamaking01:20150508012455p:plain
 
 
上記のサイトの説明だと、ダウンロードについての記述部分の下に、すぐ使用できると書いてあった。
が、その下に「上記のライブラリを使いたい場合は、ビルドが必要です」と書いてあるので一応。
 
下記の2つを実施するように書いてあるが、見当たらず。
./bootstrap
./bjam
 
上記サイトに記載されたオフィシャルのビルドの解説(Boost Getting Started - 1.58.0)を読んだ。
 

$ cd path/to/boost_1_58_0
$ ./bootstrap.sh --help

 
と書いてあり、それらしきフォルダに移動して「bootstrap.sh」を実行した。

$ find / -name bootstrap.sh 2> /dev/null
/Library/boost/bootstrap.sh
/Library/boost/tools/build/bootstrap.sh
$ /Library/boost/bootstrap.sh
/Library/boost/bootstrap.sh: line 188: ./tools/build/src/engine/build.sh: No such file or directory
-n Building Boost.Build engine with toolset ... 

Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
$ 


「./tools/build/src/engine/build.sh」が無いため、/Library/boost/bootstrap.shが実行できないとのこと。
別でインストールが必要なのかと思ったが、このコマンド(/Library/boost/bootstrap.sh)は相対パスで自分から見て./tools/build/src/engine/配下にあるbuild.shを実行している様子。
/Library/boost/bootstrap.shがある/Library/boost/配下に移動してから実行する必要があるので移動してやってみる。
 

$ cd /Library/boost/
$ /Library/boost/bootstrap.sh
-n Building Boost.Build engine with toolset darwin... 
tools/build/src/engine/bin.macosxx86_64/b2
-n Detecting Python version... 
2.7
-n Detecting Python root... 
/System/Library/Frameworks/Python.framework/Versions/2.7
-n Unicode/ICU support for Boost.Regex?... 
not found.
Generating Boost.Build configuration in project-config.jam...

Bootstrapping is done. To build, run:

    ./b2
    
To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help
     
   - Getting started guide: 
     http://www.boost.org/more/getting_started/unix-variants.html
     
   - Boost.Build documentation:
     http://www.boost.org/build/doc/html/index.html

$ 

 
ビルドできた???ぽい。