g++ 4.6 没有按照头文件 cstring 的要求发出 <bits/c++config.h> 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9201521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
g++ 4.6 issue no <bits/c++config.h> file as required by the header cstring
提问by A. K.
There is no file called bits/c++config.h
in the c++ include directory which is required by the cstring
header file. But when I include the the header cstring
and compile with g++
, it does not give me error. The problem occurred when I tried to compile the program with clang++
compiler in the following way.
头文件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>
I am using g++ 4.6.1 on Ubuntu 11.04
我在 Ubuntu 11.04 上使用 g++ 4.6.1
What went wrong?
什么地方出了错?
回答by rodrigo
The file bits/c++config.h
is the platform specific include relative to the current compiler, so it is hidden in another directory, searched by default by g++, but not by clang++, as it seems.
该文件bits/c++config.h
是相对于当前编译器的特定于平台的包含,因此它隐藏在另一个目录中,默认情况下由 g++ 搜索,但似乎不是由 clang++ 搜索。
In my machine, running locate c++config.h
gives the following (relevant) files:
在我的机器上,运行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
The first one is for 64-bits and the second one for 32-bits.
第一个用于 64 位,第二个用于 32 位。
So just add -I/usr/include/c++/4.6/i686-linux-gnu
or -I/usr/include/c++/4.6/i686-linux-gnu/64
or whatever you need for your platform.
因此,只需添加-I/usr/include/c++/4.6/i686-linux-gnu
或添加-I/usr/include/c++/4.6/i686-linux-gnu/64
您的平台所需的任何内容。
回答by Coren
It can be related to how clang++ search its headers files.
它可能与 clang++ 搜索其头文件的方式有关。
You'll find a sample patch of how they fix it for fedora 15, 4 months ago, here.
您将在 4 个月前找到他们如何为 Fedora 修复它的示例补丁,请点击此处。
See this red hat bugzilla postfor more info.
有关更多信息,请参阅此red hat bugzilla 帖子。