« [ security ] Gmail ユーザを狙ったフィッシング詐欺? | トップページ | [ レビュー ] Acer Iconia Tab A500 »

2011/06/02

[ ubuntu ] パッケージインストールした clang でインクルードエラー

Ubuntu 11.04 でパッケージインストール ( aptitude install ) した clang で C++ ソースをコンパイルしようとすると、インクルードエラーになります。

サンプルソース

#include <iostream>

int main( void )
{
        std::cout << "Hello, World." << std::endl;
        return 0;
}

clang でコンパイル。

$ clang test.cpp 
test.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
         ^
1 error generated.

この原因は、aptitude でインストールされる clang が GCC4.5 環境で使われることを前提にしていないことにあります。

$ clang -v -x c++ /dev/null -fsyntax-only
clang version 2.8 (branches/release_28)
Target: i386-pc-linux-gnu
Thread model: posix
 "/usr/bin/clang" -cc1 -triple i386-pc-linux-gnu -fsyntax-only -disable-free -disable-llvm-verifier -main-file-name null -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.21.0.20110216 -v -resource-dir /usr/lib/clang/2.8 -ferror-limit 19 -fmessage-length 80 -fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -x c++ /dev/null
clang -cc1 version 2.8 based upon llvm 2.8rc hosted on i386-pc-linux-gnu
ignoring nonexistent directory "/usr/include/c++/4.4"
ignoring nonexistent directory "/usr/include/c++/4.4/x86_64-linux-gnu/32"
ignoring nonexistent directory "/usr/include/c++/4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4"
ignoring nonexistent directory "/usr/include/c++/4.4/i486-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/x86_64-linux-gnu/32"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/i486-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/arm-linux-gnueabi/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.2"
ignoring nonexistent directory "/usr/include/c++/4.2/x86_64-linux-gnu/32"
ignoring nonexistent directory "/usr/include/c++/4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.2"
ignoring nonexistent directory "/usr/include/c++/4.2/i486-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.1"
ignoring nonexistent directory "/usr/include/c++/4.1/x86_64-linux-gnu/32"
ignoring nonexistent directory "/usr/include/c++/4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.1"
ignoring nonexistent directory "/usr/include/c++/4.1/i486-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.4"
ignoring nonexistent directory "/usr/include/c++/4.4.4/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.4"
ignoring nonexistent directory "/usr/include/c++/4.4.4/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3"
ignoring nonexistent directory "/usr/include/c++/4.4.3/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3"
ignoring nonexistent directory "/usr/include/c++/4.4.3/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.2"
ignoring nonexistent directory "/usr/include/c++/4.4.2/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.2"
ignoring nonexistent directory "/usr/include/c++/4.4.2/i686-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.1"
ignoring nonexistent directory "/usr/include/c++/4.4.1/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.1"
ignoring nonexistent directory "/usr/include/c++/4.4.1/i586-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.2"
ignoring nonexistent directory "/usr/include/c++/4.3.2/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.3.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.2"
ignoring nonexistent directory "/usr/include/c++/4.3.2/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.0"
ignoring nonexistent directory "/usr/include/c++/4.3.0/x86_64-redhat-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.3.0/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.0"
ignoring nonexistent directory "/usr/include/c++/4.3.0/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3.0/backward"
ignoring nonexistent directory "/usr/include/c++/4.1.2"
ignoring nonexistent directory "/usr/include/c++/4.1.2/x86_64-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.1.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.1.2"
ignoring nonexistent directory "/usr/include/c++/4.1.2/i386-redhat-linux/"
ignoring nonexistent directory "/usr/include/c++/4.1.2/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3"
ignoring nonexistent directory "/usr/include/c++/4.4.3/x86_64-pc-linux-gnu/32"
ignoring nonexistent directory "/usr/include/c++/4.4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.4.3"
ignoring nonexistent directory "/usr/include/c++/4.4.3/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/i586-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.3"
ignoring nonexistent directory "/usr/include/c++/4.3/x86_64-suse-linux/32"
ignoring nonexistent directory "/usr/include/c++/4.3/backward"
ignoring nonexistent directory "/usr/include/c++/4.4"
ignoring nonexistent directory "/usr/include/c++/4.4/i586-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.4"
ignoring nonexistent directory "/usr/include/c++/4.4/x86_64-suse-linux/"
ignoring nonexistent directory "/usr/include/c++/4.4/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.1"
ignoring nonexistent directory "/usr/include/c++/4.3.1/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3.1/backward"
ignoring nonexistent directory "/usr/include/c++/4.3.1"
ignoring nonexistent directory "/usr/include/c++/4.3.1/x86_64-unknown-linux-gnu/"
ignoring nonexistent directory "/usr/include/c++/4.3.1/backward"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.3.2/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/i686-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/x86_64-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.3.2/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4/x86_64-pc-linux-gnu/32"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/include/g++-v4/backward"
ignoring nonexistent directory "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1"
ignoring nonexistent directory "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/x86_64-pc-linux-gnu/"
ignoring nonexistent directory "/usr/lib/llvm-gcc-4.2-9999/include/c++/4.2.1/backward"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/clang/2.8/include
 /usr/include
End of search list.

GCC4.4 を入れるか自前でビルドしなおしたほうがいいでしょう ( clang のヘッダサーチパスはハードコーディングされています。また、-I オプションでパスを指定する方法もありますがお勧めできません )。

|

« [ security ] Gmail ユーザを狙ったフィッシング詐欺? | トップページ | [ レビュー ] Acer Iconia Tab A500 »

コメント

コメントを書く



(ウェブ上には掲載しません)


コメントは記事投稿者が公開するまで表示されません。



トラックバック

この記事のトラックバックURL:
http://app.cocolog-nifty.com/t/trackback/103108/51834375

この記事へのトラックバック一覧です: [ ubuntu ] パッケージインストールした clang でインクルードエラー:

» clangインストール完了後記 [uma_yの求職とか日報]
はじめてのはてなダイアリーでいきなりだけど、clangをインストールしたのでそのときのメモをば。OSはUbuntu11.04です。 前提 http://foma-zakki.cocolog-nifty.com/zakki/2011/06/ubuntu-clang-6f.html 上記ページから 1. c++のコンパイルもclangコマンドでよいと思った。 ... [続きを読む]

受信: 2011/07/22 01時20分

« [ security ] Gmail ユーザを狙ったフィッシング詐欺? | トップページ | [ レビュー ] Acer Iconia Tab A500 »