Can't use the Makefile in llvm/tools/clang/examples/wpa

Hi,

I want to build the clang-wpa tool but failed to use the Makefile under that
directory. If I make it then I get the error:

../../../../Makefile.common:61: ../../../../Makefile.config: No such file or
directory
../../../../Makefile.common:69: /Makefile.rules: No such file or directory
make: *** No rule to make target `/Makefile.rules'. Stop.

Does anyone know what the problem is?
Thanks in advance.--
View this message in context: http://clang-developers.42468.n3.nabble.com/Can-t-use-the-Makefile-in-llvm-tools-clang-examples-wpa-tp2884938p2884938.html

Forgot to mention that I'm using Clang on Linux.

Also I've tried to compile clang-wpa.cpp using the following command:
clang++ clang-wpa.cpp -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS
-I/usr/local/include -lclangFrontend -lclangDriver -lclangCodeGen
-lclangSema -lclangAnalysis -lclangRewrite -lclangAST -lclangParse
-lclangLex -lclangIndex -lclangBasic `llvm-config --cxxflags --ldflags
--libs`

But I got the following error message:
/tmp/cc-T7JXvS.o: In function `main':
/home/chenliu/clang-wpa.cpp:155: undefined reference to
`clang::ento::CreateRegionStoreManager(clang::ento::GRStateManager&)'
/home/chenliu/clang-wpa.cpp:155: undefined reference to
`clang::ento::CreateRangeConstraintManager(clang::ento::GRStateManager&,
clang::ento::SubEngine&)'
/home/chenliu/clang-wpa.cpp:159: undefined reference to
`clang::ento::registerCheckers(clang::AnalyzerOptions const&,
clang::LangOptions const&, clang::Diagnostic&)'
/home/chenliu/clang-wpa.cpp:165: undefined reference to
`clang::ento::CreateRangeConstraintManager(clang::ento::GRStateManager&,
clang::ento::SubEngine&)'
/home/chenliu/clang-wpa.cpp:165: undefined reference to
`clang::ento::CreateRegionStoreManager(clang::ento::GRStateManager&)'
/home/chenliu/clang-wpa.cpp:175: undefined reference to
`clang::ento::MakeCFRefCountTF(clang::ASTContext&, bool, clang::LangOptions
const&)'
/home/chenliu/clang-wpa.cpp:176: undefined reference to
`clang::ento::ExprEngine::ExprEngine(clang::ento::AnalysisManager&,
clang::ento::TransferFuncs*)'
/home/chenliu/clang-wpa.cpp:181: undefined reference to
`clang::ento::ExprEngine::~ExprEngine()'
/tmp/cc-T7JXvS.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-T7JXvS.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-T7JXvS.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-T7JXvS.o: In function
`clang::ento::AnalysisManager::~AnalysisManager()':
/usr/local/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h:99:
undefined reference to `clang::ento::BugReporterData::~BugReporterData()'
/tmp/cc-T7JXvS.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'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`clang::ASTUnit::LoadFromASTFile(std::string const&,
llvm::IntrusiveRefCntPtr<clang::Diagnostic>, clang::FileSystemOptions
const&, bool, std::pair&lt;std::string, llvm::PointerUnion&lt;char const*,
llvm::MemoryBuffer const*&gt; >*, unsigned int, bool)':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:581: undefined
reference to `clang::ASTReader::ASTReader(clang::SourceManager&,
clang::FileManager&, clang::Diagnostic&, char const*, bool, bool)'
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:585: undefined
reference to `clang::ASTReader::ReadAST(std::string const&,
clang::ASTReader::ASTFileType)'
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:616: undefined
reference to `clang::ASTReader::setPreprocessor(clang::Preprocessor&)'
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:629: undefined
reference to `clang::ASTReader::InitializeContext(clang::ASTContext&)'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`PrecompilePreambleConsumer':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:765: undefined
reference to `clang::PCHGenerator::PCHGenerator(clang::Preprocessor const&,
std::string const&, bool, char const*, llvm::raw_ostream*)'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function `(anonymous
namespace)::PrecompilePreambleConsumer::HandleTranslationUnit(clang::ASTContext&)':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:784: undefined
reference to
`clang::PCHGenerator::HandleTranslationUnit(clang::ASTContext&)'
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:792: undefined
reference to `clang::ASTWriter::getDeclID(clang::Decl const*)'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`clang::ASTUnit::serialize(llvm::raw_ostream&)':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:2177: undefined
reference to `clang::ASTWriter::ASTWriter(llvm::BitstreamWriter&)'
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:2178: undefined
reference to `clang::ASTWriter::WriteAST(clang::Sema&,
clang::MemorizeStatCalls*, std::string const&, char const*)'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`~PrecompilePreambleConsumer':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:755: undefined
reference to `clang::ASTSerializationListener::~ASTSerializationListener()'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`~ASTInfoCollector':
/home/chenliu/llvm/tools/clang/lib/Frontend/ASTUnit.cpp:370: undefined
reference to `clang::ASTReaderListener::~ASTReaderListener()'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`ASTReaderListener':
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTReader.h:89:
undefined reference to `vtable for clang::ASTReaderListener'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function `~ASTWriter':
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTWriter.h:68:
undefined reference to `vtable for clang::ASTWriter'
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTWriter.h:68:
undefined reference to `vtable for clang::ASTWriter'
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTWriter.h:68:
undefined reference to
`clang::ASTDeserializationListener::~ASTDeserializationListener()'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function `~PCHGenerator':
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTWriter.h:596:
undefined reference to `vtable for clang::PCHGenerator'
/usr/local/lib/libclangFrontend.a(ASTUnit.o): In function
`ASTSerializationListener':
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTSerializationListener.h:25:
undefined reference to `vtable for clang::ASTSerializationListener'
/usr/local/lib/libclangFrontend.a(ASTUnit.o):(.data.rel.ro+0x118): undefined
reference to `clang::PCHGenerator::GetASTMutationListener()'
/usr/local/lib/libclangFrontend.a(ASTUnit.o):(.data.rel.ro+0x120): undefined
reference to `clang::PCHGenerator::GetASTDeserializationListener()'
/usr/local/lib/libclangFrontend.a(CompilerInstance.o): In function
`clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef,
std::string const&, bool, bool, clang::Preprocessor&, clang::ASTContext&,
void*, bool)':
/home/chenliu/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:291:
undefined reference to `clang::ASTReader::ASTReader(clang::Preprocessor&,
clang::ASTContext*, char const*, bool, bool)'
/home/chenliu/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:294:
undefined reference to
`clang::ASTReader::setDeserializationListener(clang::ASTDeserializationListener*)'
/home/chenliu/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:295:
undefined reference to `clang::ASTReader::ReadAST(std::string const&,
clang::ASTReader::ASTFileType)'
/usr/local/lib/libclangFrontend.a(FrontendAction.o): In function
`clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&,
llvm::StringRef, clang::InputKind)':
/home/chenliu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:216:
undefined reference to
`clang::ChainedIncludesSource::create(clang::CompilerInstance&)'
/usr/local/lib/libclangFrontend.a(FrontendAction.o): In function
`~DeserializedDeclsChecker':
/home/chenliu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:53: undefined
reference to
`clang::ASTDeserializationListener::~ASTDeserializationListener()'
/usr/local/lib/libclangFrontend.a(FrontendAction.o): In function
`~DeserializedDeclsDumper':
/home/chenliu/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:33: undefined
reference to
`clang::ASTDeserializationListener::~ASTDeserializationListener()'
/usr/local/lib/libclangFrontend.a(FrontendAction.o): In function
`ASTDeserializationListener':
/home/chenliu/llvm/tools/clang/lib/Frontend/../../include/clang/Serialization/ASTDeserializationListener.h:27:
undefined reference to `vtable for clang::ASTDeserializationListener'
/usr/local/lib/libclangFrontend.a(FrontendActions.o): In function
`clang::GeneratePCHAction::CreateASTConsumer(clang::CompilerInstance&,
llvm::StringRef)':
/home/chenliu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp:87:
undefined reference to
`clang::PCHGenerator::PCHGenerator(clang::Preprocessor const&, std::string
const&, bool, char const*, llvm::raw_ostream*)'
/usr/local/lib/libclangFrontend.a(MultiplexConsumer.o): In function
`clang::MultiplexASTDeserializationListener::~MultiplexASTDeserializationListener()':
MultiplexConsumer.cpp:(.text._ZN5clang35MultiplexASTDeserializationListenerD2Ev[_ZN5clang35MultiplexASTDeserializationListenerD5Ev]+0x36):
undefined reference to
`clang::ASTDeserializationListener::~ASTDeserializationListener()'
/usr/local/lib/libclangFrontend.a(CompilerInvocation.o): In function
`ParsePreprocessorArgs':
/home/chenliu/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp:1617:
undefined reference to `clang::ASTReader::getOriginalSourceFile(std::string
const&, clang::FileManager&, clang::Diagnostic&)'
clang: error: linker command failed with exit code 1 (use -v to see
invocation)

Did you run ./configure in the llvm directory first? See
http://clang.llvm.org/get_started.html

Running `make` in tools/clang/examples/wpa works fine for me.

Nico

Thanks. Your advice works.

Now I'm not sure how to use the command "clang-wpa".
I built an ast file test.ast and then run

clang-wpa -view-call-graph test.ast

But the progrem shows nothing. Is there anything I did wrong?--
View this message in context: http://clang-developers.42468.n3.nabble.com/Can-t-use-the-Makefile-in-llvm-tools-clang-examples-wpa-tp2884938p2888273.html