Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

llvm-clang

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;
    }
like image 401
ConfusedAboutCPP Avatar asked May 23 '11 16:05

ConfusedAboutCPP


2 Answers

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.

like image 104
osgx Avatar answered Sep 25 '22 15:09

osgx


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

like image 22
Ruslan Avatar answered Sep 26 '22 15:09

Ruslan