<br><br><div class="gmail_quote">On Tue, May 18, 2010 at 10:11 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><div></div><div class="h5"><br><div><div>On May 18, 2010, at 6:09 AM, Jiandong Wang wrote:</div><br><blockquote type="cite">Hi all:<div>    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.  </div>

<div>here is my code snippet:</div>

<div><br></div></blockquote></div></div></div><div>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.</div></div></blockquote>

<div> </div><div> Thank you. I finally compiled it through.my command:</div><div>       g++ `llvm-config --cxxflags --ldflags` -fno-rtti -c Myfile.cpp -o Myfile.o</div><div>but when I generated the executable, unexpected errors occured. my command:</div>

<div>       g++ `llvm-config --cxxflasg --ldflags --libs core` -o Myfile Myfile.o </div><div><br></div><div>errors like this:</div><div>undefined reference to 'llvm::errs()'</div><div>undefined reference to 'clang::Diagnostic::Diagnostic(clang::DiagnosticClient*)'</div>

<div>undefined reference to 'clang::FileManager::FileManager()'</div><div><br></div><div>missing something? </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><div><br></div><div>Have you considered using CompilerInvocation/CompilerInstance rather than building all of the pieces together?</div><div><br></div></div></blockquote><div>  Yes, I knew. I will try it later. -:)</div>

</div><br>