Ubuntu 11.10でIntel C++でBoostを使えるようにする

C++の準標準ライブラリーBoostIntel C++から使えるように設定する。Boostのいくつかのライブラリーは動的ライブラリーにしないと使えない。なので、Intel C++から使いたい場合はIntel C++でその動的ライブラリーをコンパイルしてやらないといけないと思う。

インストール

以下のライブラリーを使いたい場合にはコンパイルが必要とのこと。

  • Boost.Filesystem
  • Boost.GraphParallel
  • Boost.IOStreams
  • Boost.MPI
  • Boost.ProgramOptions
  • Boost.Python (see the Boost.Python build documentation before building and installing it)
  • Boost.Regex
  • Boost.Serialization
  • Boost.Signals
  • Boost.System
  • Boost.Thread
  • Boost.Wave

こちらも同様。ただしコンパイルに他のライブラリーやソフトウェアが必要。

  • Boost.DateTime
  • Boost.Graph
  • Boost.Math
  • Boost.Random
  • Boost.Test

インストールする。Boost Official: Getting Started on Unix Variantsに書いてあるとおりにやる。ただし、いろいろとオプションつける必要あり。コンパイルには時間がかかる。

% tar xvfj boost_1_48_0.tar.bz2
% cd boost_1_48_0
% ./bootstrap.sh --prefix=/usr/local --with-toolset=intel
% sudo ./b2 install --prefix=/usr/local toolset=intel-12.0 cflags="-I /usr/include/i386-linux-gnu"

補足。toolsetの設定でintelだけを指定すると /opt/intel_cc_80/bin が指定される。多分設定ファイルは boost_1_48_0/tools/build/v2/tools/intel-linux.jam。このファイルでversionによって読み込むディレクトリを変えている。Boostライブラリのビルド方法にあるバージョン指定の方法のとおりに指定した。

共有ライブラリーのパスが通っているかを確認する。

% ldconfig -p | grep boost

ちゃんとパスがとおっていなければ

% sudo ldconfig
% ldconfig -p | grep boost

それでもだめならば、/etc/ld.so.conf.d/ 以下に boost.conf を作成し、ファイルの中身を以下のようにする。私の場合はlibc.confに/usr/local/libが記載されていたので問題なかった。

# For boost libraries
/usr/local/lib

作動テスト

凹みTips:コマンドライン引数をboost::program_optionsで格納にあるprogram_optionsを用いたサンプルプログラムをコピーして、コンパイルしてみる。ファイル名をTestOptionChecker.cppとする。

% icpc TestOptionChecker.cpp -lboost_program_options
% ./a.out

ちゃんと動けばBoostのインストール成功。