Libclang: error: clang-c / Index.h: There is no such file or directory

I tried to use clang to parse C ++ code but could not compile the source code because I cannot find the libclang headers.

I am running ubuntu 10.04 and successfully installed clang and llvm from the repositories.

Please tell me where to find the file to include.

An example I'm trying to run:

#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; } 
+6
source share
2 answers

The ubuntu 10.04 clang-2.7 package http://packages.ubuntu.com/lucid/devel/clang does not include the clang-c/Index.h header file, nor does it have libclang.so:

http://packages.ubuntu.com/lucid/i386/clang/filelist

Not a single llvm-dev package: http://packages.ubuntu.com/lucid/i386/llvm-dev/filelist

So, ubuntu 10.04 does not have a clang package with libclang or anything related to the development of clang.

As Banthar suggested, you should use clang from the llvm site, either built from sources (this is easy in ubuntu) or packaged as a binary package.

+4
source

As Adam Monsen said in a comment on the accepted answer, starting with Ubuntu 13.10, the file is provided with the following package:

libclang-3.4-dev

Change the version number to suit your requirements. The file is in

/usr/lib/llvm-3.4/include/clang-c/Index.h

+2
source

Source: https://habr.com/ru/post/888835/


All Articles