21

ヘッダー ファイルbits/c++config.hに必要な c++ インクルード ディレクトリに呼び出されるファイルがありません。cstringしかし、ヘッダーcstringをインクルードしてコンパイルするとg++、エラーは発生しません。clang++ 以下の方法でコンパイラーでプログラムをコンパイルしようとしたところ、問題が発生しました。

$clang++ -cc1 -I/usr/include -I/usr/include/c++/4.6.1 -I/usr/lib/gcc/i686-linux-gnu/4.6.1 -I/usr/include/i386-linux-gnu -I opt_149739_build/include hello.cpp

In file included from /media/space/hello.cpp:2:
In file included from /media/space/opt_149739_build/include/clang/Driver/Driver.h:13:
In file included from /media/space/opt_149739_build/include/clang/Basic/Diagnostic.h:17:
In file included from /media/space/opt_149739_build/include/clang/Basic/DiagnosticIDs.h:18:
In file included from /media/space/opt_149739_build/include/llvm/ADT/StringRef.h:14:
/usr/include/c++/4.6.1/cstring:42:10: fatal error: 'bits/c++config.h' file not found
#include <bits/c++config.h>

Ubuntu 11.04 で g++ 4.6.1 を使用しています

何が悪かったのか?

4

2 に答える 2

32

このファイルbits/c++config.hは、現在のコンパイラに関連するプラットフォーム固有のインクルードであるため、別のディレクトリに隠され、デフォルトで g++ によって検索されますが、clang++ では検索されないようです。

私のマシンでは、実行locate c++config.hすると次の(関連する)ファイルが得られます。

/usr/include/c++/4.6/i686-linux-gnu/64/bits/c++config.h
/usr/include/c++/4.6/i686-linux-gnu/bits/c++config.h

1 つ目は 64 ビット用で、2 つ目は 32 ビット用です。

したがって、プラットフォームに必要なものを追加するだけ-I/usr/include/c++/4.6/i686-linux-gnuです。-I/usr/include/c++/4.6/i686-linux-gnu/64

于 2012-02-08T22:28:22.020 に答える
0

これは、clang++ がヘッダー ファイルを検索する方法に関連している可能性があります。

4 か月前の fedora 15 向けの修正方法のサンプル パッチがここにあります。

詳細については、このred Hat bugzilla の投稿を参照してください。

于 2012-02-08T22:32:16.200 に答える