[cfe-dev] 回复: 回复: 转发: 回复: Fail to compile clang-wpa.cpp

kobe James god.son2046 at yahoo.com.cn
Sun Apr 24 19:06:23 PDT 2011


Sorry to bring trouble for you...I tried using llvm-config:

clang++ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS clang-wpa.cpp -o 
clang-wpa `llvm-config --cxxflags --ldflags --libs`

Now the error message become:
/tmp/cc-9Ywol6.o: In function `main':
/home/chenliu/clang-wpa.cpp:96: undefined reference to 
`clang::idx::Program::Program()'
/home/chenliu/clang-wpa.cpp:104: undefined reference to 
`clang::CompilerInstance::createDiagnostics(clang::DiagnosticOptions const&, 
int, char const* const*, clang::DiagnosticClient*, clang::CodeGenOptions 
const*)'
/home/chenliu/clang-wpa.cpp:107: undefined reference to 
`clang::ASTUnit::LoadFromASTFile(std::string const&, 
llvm::IntrusiveRefCntPtr<clang::Diagnostic>, clang::FileSystemOptions const&, 
bool, std::pair<std::string, llvm::PointerUnion<char const*, llvm::MemoryBuffer 
const*> >*, unsigned int, bool)'
/home/chenliu/clang-wpa.cpp:118: undefined reference to 
`clang::CallGraph::CallGraph(clang::idx::Program&)'
/home/chenliu/clang-wpa.cpp:121: undefined reference to 
`clang::CallGraph::addTU(clang::ASTContext&)'
/home/chenliu/clang-wpa.cpp:123: undefined reference to 
`clang::CallGraph::ViewCallGraph() const'
/home/chenliu/clang-wpa.cpp:133: undefined reference to 
`clang::idx::Indexer::IndexAST(clang::idx::TranslationUnit*)'
/home/chenliu/clang-wpa.cpp:136: undefined reference to 
`clang::idx::Entity::get(llvm::StringRef, clang::idx::Program&)'
/home/chenliu/clang-wpa.cpp:139: undefined reference to 
`clang::idx::Indexer::getDefinitionFor(clang::idx::Entity)'
/home/chenliu/clang-wpa.cpp:165: undefined reference to 
`clang::ento::CreateRegionStoreManager(clang::ento::GRStateManager&)'
/home/chenliu/clang-wpa.cpp:165: undefined reference to 
`clang::ento::CreateRangeConstraintManager(clang::ento::GRStateManager&, 
clang::ento::SubEngine&)'
/home/chenliu/clang-wpa.cpp:169: undefined reference to 
`clang::ento::registerCheckers(clang::AnalyzerOptions const&, clang::LangOptions 
const&, clang::Diagnostic&)'
/home/chenliu/clang-wpa.cpp:175: undefined reference to 
`clang::ento::CreateRangeConstraintManager(clang::ento::GRStateManager&, 
clang::ento::SubEngine&)'
/home/chenliu/clang-wpa.cpp:175: undefined reference to 
`clang::ento::CreateRegionStoreManager(clang::ento::GRStateManager&)'
/home/chenliu/clang-wpa.cpp:185: undefined reference to 
`clang::ento::MakeCFRefCountTF(clang::ASTContext&, bool, clang::LangOptions 
const&)'
/home/chenliu/clang-wpa.cpp:186: undefined reference to 
`clang::ento::ExprEngine::ExprEngine(clang::ento::AnalysisManager&, 
clang::ento::TransferFuncs*)'
/home/chenliu/clang-wpa.cpp:191: undefined reference to 
`clang::ento::ExprEngine::~ExprEngine()'
/home/chenliu/clang-wpa.cpp:191: undefined reference to 
`clang::idx::Program::~Program()'
/tmp/cc-9Ywol6.o: In function `(anonymous 
namespace)::ASTUnitTU::ASTUnitTU(clang::ASTUnit*)':
/home/chenliu/clang-wpa.cpp:67: undefined reference to 
`clang::idx::DeclReferenceMap::DeclReferenceMap(clang::ASTContext&)'
/home/chenliu/clang-wpa.cpp:67: undefined reference to 
`clang::idx::SelectorMap::SelectorMap(clang::ASTContext&)'
/tmp/cc-9Ywol6.o: In function `(anonymous namespace)::ASTUnitTU::~ASTUnitTU()':
/home/chenliu/clang-wpa.cpp:60: undefined reference to 
`clang::idx::TranslationUnit::~TranslationUnit()'
/tmp/cc-9Ywol6.o: In function 
`llvm::OwningPtr<clang::CallGraph>::reset(clang::CallGraph*)':
/usr/local/include/llvm/ADT/OwningPtr.h:45: undefined reference to 
`clang::CallGraph::~CallGraph()'
/tmp/cc-9Ywol6.o: In function 
`llvm::OwningPtr<clang::ento::CheckerManager>::reset(clang::ento::CheckerManager*)':

/usr/local/include/llvm/ADT/OwningPtr.h:45: undefined reference to 
`clang::ento::CheckerManager::~CheckerManager()'
/tmp/cc-9Ywol6.o: In function 
`clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*, 
unsigned int)':
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:89: 
undefined reference to 
`clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, 
unsigned int, clang::ento::GRState const*)'
/tmp/cc-9Ywol6.o: In function 
`clang::ento::AnalysisManager::getStackFrame(clang::Decl const*, 
clang::idx::TranslationUnit*)':
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:203:
 undefined reference to `clang::AnalysisContextManager::getContext(clang::Decl 
const*, clang::idx::TranslationUnit*)'
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:203:
 undefined reference to 
`clang::LocationContextManager::getStackFrame(clang::AnalysisContext*, 
clang::LocationContext const*, clang::Stmt const*, clang::CFGBlock const*, 
unsigned int)'
/tmp/cc-9Ywol6.o: In function 
`llvm::OwningPtr<clang::ento::CheckerManager>::~OwningPtr()':
/usr/local/include/llvm/ADT/OwningPtr.h:35: undefined reference to 
`clang::ento::CheckerManager::~CheckerManager()'
/tmp/cc-9Ywol6.o: In function `llvm::OwningPtr<clang::CallGraph>::~OwningPtr()':
/usr/local/include/llvm/ADT/OwningPtr.h:35: undefined reference to 
`clang::CallGraph::~CallGraph()'
/tmp/cc-9Ywol6.o: In function `llvm::OwningPtr<clang::ASTUnit>::~OwningPtr()':
/usr/local/include/llvm/ADT/OwningPtr.h:35: undefined reference to 
`clang::ASTUnit::~ASTUnit()'
/tmp/cc-9Ywol6.o: In function 
`llvm::RefCountedBase<clang::Diagnostic>::Release() const':
/usr/local/include/llvm/ADT/IntrusiveRefCntPtr.h:53: undefined reference to 
`clang::Diagnostic::~Diagnostic()'
/tmp/cc-9Ywol6.o: In function `clang::idx::Indexer::~Indexer()':
/usr/local/include/clang/Index/Indexer.h:33: undefined reference to `vtable for 
clang::idx::Indexer'
/usr/local/include/clang/Index/Indexer.h:33: undefined reference to 
`clang::idx::IndexProvider::~IndexProvider()'
/tmp/cc-9Ywol6.o: In function 
`clang::ento::AnalysisManager::~AnalysisManager()':
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:99: 
undefined reference to 
`clang::LocationContextManager::~LocationContextManager()'
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:99: 
undefined reference to 
`clang::AnalysisContextManager::~AnalysisContextManager()'
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:99: 
undefined reference to `clang::ento::BugReporterData::~BugReporterData()'
/tmp/cc-9Ywol6.o: In function `clang::ento::BugReporterData::BugReporterData()':
/usr/local/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:270: 
undefined reference to `vtable for clang::ento::BugReporterData'
/tmp/cc-9Ywol6.o: In function `clang::idx::TranslationUnit::TranslationUnit()':
/usr/local/include/clang/Index/TranslationUnit.h:27: undefined reference to 
`vtable for clang::idx::TranslationUnit'
/tmp/cc-9Ywol6.o: In function 
`clang::idx::Indexer::Indexer(clang::idx::Program&)':
/usr/local/include/clang/Index/Indexer.h:42: undefined reference to `vtable for 
clang::idx::Indexer'
/tmp/cc-9Ywol6.o: In function `clang::idx::IndexProvider::IndexProvider()':
/usr/local/include/clang/Index/IndexProvider.h:25: undefined reference to 
`vtable for clang::idx::IndexProvider'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
============================================

Hope this can give you more info.

Thanks a lot!




________________________________
发件人: kobe James <god.son2046 at yahoo.com.cn>
收件人: Óscar Fuentes <ofv at wanadoo.es>
抄   送: cfe-dev at cs.uiuc.edu
发送日期: 2011/4/24 (周日) 7:26:02 下午
主   题: [cfe-dev] 回复:  转发: 回复: Fail to compile clang-wpa.cpp


Thanks for replying. Could you give more details?

I installed LLVM and Clang following the instructions in 
http://clang.llvm.org/get_started.html. I also tried to modify the 
clang/lib/Frontend/InitHeaderSearch.cpp file but it didn't help. I couldn't 
figure out how I missed those liabraries. What else should I do?




________________________________
发件人: Óscar Fuentes <ofv at wanadoo.es>
收件人: cfe-dev at cs.uiuc.edu
抄   送: kobe James <public-god.son2046-/E1597aS9LRv1O+Z8WTAqQ at lo.gmane.org>
发送日期: 2011/4/24 (周日) 10:38:17 上午
主   题: Re: [cfe-dev] 转发: 回复: Fail to compile clang-wpa.cpp

arrowdodger <6yearold at gmail.com> writes:

>> I have changed the command to
>>
>> clang++ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS clang-wpa.cpp -o
>> clang-wpa
>>
>> And I got the following errors:
>>
>
> As i said, use llvm-config script. It will give you all necessary flags
> needed to compile your program.

Actually, he's missing the list of required libraries. Including the
clang ones which are not provided by  llvm-config.

My advice to the OP is to learn first how to invoke a C++ compiler,
what's a linker and how to use them in the generic case.

_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110425/70b2bdd2/attachment.html>


More information about the cfe-dev mailing list