[cfe-dev] ASTContext: how to get an object or pointer of ASTContext

Jiandong Wang computerhenu at gmail.com
Tue May 18 19:30:46 PDT 2010


the same errors are still there. But when I use -lCIndex instead of
-lclangBasic(etc.),  it links successfully. Another error appears when it
comes to running the executable(by ./Myfile).
error like this:
error while loading shared libraries: libCIndex.so: cannot open shared
object file: No such file or directory


On Wed, May 19, 2010 at 9:22 AM, Douglas Gregor <dgregor at apple.com> wrote:

>
> On May 18, 2010, at 6:19 PM, Jiandong Wang wrote:
>
>
>
> On Tue, May 18, 2010 at 10:11 PM, Douglas Gregor <dgregor at apple.com>wrote:
>
>>
>> On May 18, 2010, at 6:09 AM, Jiandong Wang wrote:
>>
>> Hi all:
>>     now I am trying to run my own ASTConsumer against AST, but not quite
>> sure how to do it, especially how to get an object or pointer of ASTContext.
>> BTW, ASTContext is required by ParseAST.
>> here is my code snippet:
>>
>> You can just create an ASTContext on the stack, passing in the various
>> other pieces (lang options, source manager, target info, etc.) when you
>> construct it.
>>
>
>  Thank you. I finally compiled it through.my command:
>        g++ `llvm-config --cxxflags --ldflags` -fno-rtti -c Myfile.cpp -o
> Myfile.o
> but when I generated the executable, unexpected errors occured. my command:
>        g++ `llvm-config --cxxflasg --ldflags --libs core` -o Myfile
> Myfile.o
>
> errors like this:
> undefined reference to 'llvm::errs()'
> undefined reference to
> 'clang::Diagnostic::Diagnostic(clang::DiagnosticClient*)'
> undefined reference to 'clang::FileManager::FileManager()'
>
> missing something?
>
>
> You need to link against the Clang libraries. -lClangBasic -lClang
> -lClangAST and so on.
>
> - Doug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100519/5dcce320/attachment.html>


More information about the cfe-dev mailing list