该法典有:
#include <cstdlib>
#include <clang-c/Index.h>
using namespace std;
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
", clang_getCString(String));
clang_disposeString(String);
}
clang_disposeTranslationUnit(TU);
clang_disposeIndex(Index);
return 0;
}
并用下列国旗汇编:
g++ main.cpp -g -fno-rtti `llvm-config --cxxflags --ldflags --libs` -lclang -o main
然而,当我想主人时:
./main
之后有以下错误:
./main: error while loading shared libraries: libclang.so: cannot open shared object file: No such file or directory
然而:
$ sudo find / -name libclang.so
/usr/local/lib/libclang.so
Library seems to be on place. How to run this program?