ConfusedAboutCPP
ConfusedAboutCPP

Reputation: 603

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

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;
    }

Upvotes: 8

Views: 12365

Answers (2)

Ruslan
Ruslan

Reputation: 19120

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

Upvotes: 5

osgx
osgx

Reputation: 94235

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.

Upvotes: 4

Related Questions