开发者

libclang: error: clang-c/Index.h: No such file or directory

开发者 https://www.devze.com 2023-03-08 06:12 出处:网络
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 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;
    }


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号