[LLVMdev] How to write Clang plugin Makefile with binary download LLVM and Clang?
朱军
jszhujun2010 at 126.com
Wed Jul 15 01:14:35 PDT 2015
Hi! I'am new to LLVM and Clang. I just followed this [tutorial](https://kevinaboos.wordpress.com/2013/07/29/clang-tutorial-part-iii-plugin-example/) and tried to build a Clang plugin on my PC.
The tutorial's makefile is simple like this:
CLANG_LEVEL := ../..
LIBRARYNAME = PluginExample
SOURCES := PluginExample.cpp
LINK_LIBS_IN_SHARED = 0
SHARED_LIBRARY = 1
include $(CLANG_LEVEL)/Makefile
However, this tutorial's LLVM and Clang is built by compiling the source, while I get LLVM(and Clang) binary online directly(with apt-get install on Ubuntu). It's installed in /usr/lib. So, I'm confused where my CLANG_LEVEL is, what does it exactly mean?
=========================================================================
I have tried another way, but it seems to be wrong and I have no idea what did I miss. So, the makefile is like this:
CXX := g++
LLVM_DIR := /usr/lib/llvm-3.5
LLVMCONFIG := /usr/lib/llvm-3.5/bin/llvm-config
PLUGIN = ParameterNameChecker
CXXFLAGS += `${LLVM_DIR}/bin/llvm-config --cxxflags`
LDFLAGS += `${LLVM_DIR}/bin/llvm-config --ldflags`
LLVMLIBS = `${LLVM_DIR}/bin/llvm-config --libs`
SOURCES = PluginExample.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXES = $(OBJECTS:.o=)
CLANGLIBS = \
-lclangTooling\
-lclangFrontendTool\
-lclangFrontend\
-lclangDriver\
-lclangSerialization\
-lclangCodeGen\
-lclangParse\
-lclangSema\
-lclangStaticAnalyzerFrontend\
-lclangStaticAnalyzerCheckers\
-lclangStaticAnalyzerCore\
-lclangAnalysis\
-lclangARCMigrate\
-lclangRewriteFrontend\
-lclangRewriteCore\
-lclangEdit\
-lclangAST\
-lclangLex\
-lclangBasic\
$(shell $(LLVMCONFIG) --libs)\
-lcurses
$(PLUGIN).so: $(PLUGIN).o
$(CXX) $(LDFLAGS) -o $(PLUGIN).so $(PLUGIN).o
$(PLUGIN).o: $(PLUGIN).cpp
$(CXX) $(CXXFLAGS) -c $(PLUGIN).cpp -o $(PLUGIN).o
clean:
-rm -fv $(PLUGIN).o $(PLUGIN).so
The compiler always complains sort of things like `undefined reference to 'clang::PluginASTAction::anchor()'`.
I'd like to provide more information if necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150715/56044bc4/attachment.html>
More information about the llvm-dev
mailing list