libclang:错误:clang-c/Index.h:没有这样的文件或目录
我试图使用 clang 来解析 C++ 代码,但无法编译我的源代码,因为我无法找到 libclang 标头。
我正在运行 ubuntu 10.04 并已从存储库成功安装 clang 和 llvm 。
请告诉我在哪里可以找到要包含的文件。
我尝试运行的示例是:
#include<clang-c/Index.h>
int main(int argc, char *argv[]) {
CXIndex Index = clang_createIndex(0, 0);
CXTranslationUnit TU = clang_parseTranslationUnit(Index, 0,argv, argc, 0, 0, CXTranslationUnit_None);
for (unsigned I = 0, N = clang_getNumDiagnostics(TU); I != N; ++I) {
CXDiagnostic Diag = clang_getDiagnostic(TU, I);
CXString String = clang_formatDiagnostic(Diag,
clang_defaultDiagnosticDisplayOptions());
fprintf(stderr, "%s\n", clang_getCString(String));
clang_disposeString(String);
}
clang_disposeTranslationUnit(TU);
clang_disposeIndex(Index);
return 0;
}
i was trying to use clang to parse c++ code, but am unable to compile my source code because i am unable to find libclang headers.
I am running ubuntu 10.04 and have installed clang and llvm successfully from the repositories.
Please tell me where to find the file to include .
The example i am trying to run is :
#include<clang-c/Index.h>
int main(int argc, char *argv[]) {
CXIndex Index = clang_createIndex(0, 0);
CXTranslationUnit TU = clang_parseTranslationUnit(Index, 0,argv, argc, 0, 0, CXTranslationUnit_None);
for (unsigned I = 0, N = clang_getNumDiagnostics(TU); I != N; ++I) {
CXDiagnostic Diag = clang_getDiagnostic(TU, I);
CXString String = clang_formatDiagnostic(Diag,
clang_defaultDiagnosticDisplayOptions());
fprintf(stderr, "%s\n", clang_getCString(String));
clang_disposeString(String);
}
clang_disposeTranslationUnit(TU);
clang_disposeIndex(Index);
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 Adam Monsen 在对已接受答案的评论中所说,从 Ubuntu 13.10 开始,该文件由以下软件包提供:
< code>libclang-3.4-dev
根据您的要求更改版本号。该文件位于
/usr/lib/llvm-3.4/include/clang-c/Index.h
As Adam Monsen said in a comment to the accepted answer, starting from Ubuntu 13.10, the file is provided by the following package:
libclang-3.4-dev
Change version number according to your requirements. The file resides in
/usr/lib/llvm-3.4/include/clang-c/Index.h
ubuntu 10.04 中的包 clang-2.7 http://packages.ubuntu.com/lucid/devel/clang< /a> 不包含头文件
clang-c/Index.h
,也没有 libclang.so:http://packages.ubuntu.com/lucid/i386/clang/filelist
llvm-dev 包也没有:http://packages.ubuntu.com/lucid/i386/llvm-dev/filelist
所以,ubuntu 10.04 没有带有 libclang 的 clang 包或与 clang 开发相关的任何内容。
正如 Banthar 建议的那样,您应该使用 llvm 站点中的 clang,无论是从源代码构建(在 ubuntu 中很容易)还是打包为二进制包。
Package clang-2.7 from ubuntu 10.04 http://packages.ubuntu.com/lucid/devel/clang doesnt include header file
clang-c/Index.h
, nor have a libclang.so:http://packages.ubuntu.com/lucid/i386/clang/filelist
Neither do llvm-dev package: http://packages.ubuntu.com/lucid/i386/llvm-dev/filelist
So, ubuntu 10.04 have no clang package with libclang or anything related to clang development.
As Banthar suggested, you should use clang from llvm site, either built from sources (it is easy in ubuntu) or packed as binary package.