我想爲我的項目使用llvm。我使用了一些來自llvm的頭文件,並在Makefile中包含了它們的路徑。我也在使用某些llvm庫(.a),它們的路徑和名稱已經包含在makefile中。當我運行生成文件時,它會生成沒有任何警告或錯誤的源代碼,但是當我使用生成的.so運行插件(對於我的項目)時,出現未定義符號的錯誤:源生成沒有錯誤/警告,但.so錯誤「未定義符號」
未定義符號:_ZTIN4llvm2cl18GenericOptionValueE
其中 「_ZTIN4llvm2cl18GenericOptionValueE」 是 「LLVM :: CL :: GenericOptionValue」
我建立LLVM上https://llvm.org/docs/GettingStarted.html
以下的命令而不論是否我鏈接的LLVM庫或不發生該錯誤。 我跟着llvm.org上的文件,但沒有取得任何成功。具體來說 - http://releases.llvm.org/2.6/docs/Projects.html和http://releases.llvm.org/2.6/docs/MakefileGuide.html#overvars 有關LLVM Makefile指南的文檔中提到了Makefile.config,但這不存在。 nayone有什麼建議嗎?
生成文件是:
CXXFLAGS=-I$(PVLIB_HOME)/include -I$(PVLIB_HOME)/include/fmruntime -I$(PVLIB_HOME)/include/fmruntime/eslapi \
-I/work/Project1/trunk/work/fastsim/Plugins/include -I/work/llvm/llvm-3.8.0/include -I/work/llvm/build/include/ --std=c++11 -I. -fPIC -c
PLUGIN_SRCDIR=Plugin
PIPELINE_MODEL_SRCDIR=Microarchitecture
BUILD_DIR=build
PLUGIN_UTILS=Utils
LIB_PATH=-L/work/llvm/build/lib
LIBS=-lLLVMSupport -lLLVMAArch64Desc -lLLVMAArch64Disassembler -lLLVMMCDisassembler -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMMC -lLLVMAArch64Utils -ldl
OBJECTS = $(BUILD_DIR)/CAInterface.o $(BUILD_DIR)/InOrderPipelineModelFactoryPlugin.o $(BUILD_DIR)/InOrderPipelineModelPluginHandler.o \
$(BUILD_DIR)/InOrderPipelineModelPlugin.o $(BUILD_DIR)/InOrder4StagePipeline.o \
$(BUILD_DIR)/AArch64Decoder.o $(BUILD_DIR)/EventHandler.o $(BUILD_DIR)/Decode.o $(BUILD_DIR)/ExecuteALU.o \
$(BUILD_DIR)/ExecutionUnit.o $(BUILD_DIR)/Fetch.o $(BUILD_DIR)/Scoreboard.o \
$(BUILD_DIR)/Scoreboard.o $(BUILD_DIR)/Write.o
#
# Build the final plugin
#
$(BUILD_DIR)/InOrderPipelineModel.so: $(OBJECTS)
$(CXX) -shared -o [email protected] $^ $(LIB_PATH) $(LIBS)
#
# Build the plugin
#
$(BUILD_DIR)/InOrderPipelineModelFactoryPlugin.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelFactoryPlugin.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/InOrderPipelineModelPlugin.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelPlugin.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/InOrderPipelineModelPluginHandler.o : $(PLUGIN_SRCDIR)/InOrderPipelineModelPluginHandler.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/CAInterface.o : $(PLUGIN_SRCDIR)/CAInterface.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
#
# Build the model
#
$(BUILD_DIR)/InOrder4StagePipeline.o : $(PIPELINE_MODEL_SRCDIR)/InOrder4StagePipeline.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/AArch64Decoder.o : $(PIPELINE_MODEL_SRCDIR)/Utils/AArch64Decoder.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/EventHandler.o : $(PIPELINE_MODEL_SRCDIR)/EventHandler.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/Decode.o : $(PIPELINE_MODEL_SRCDIR)/Components/Decode.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/ExecuteALU.o : $(PIPELINE_MODEL_SRCDIR)/Components/ExecuteALU.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/ExecutionUnit.o : $(PIPELINE_MODEL_SRCDIR)/Components/ExecutionUnit.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/Fetch.o : $(PIPELINE_MODEL_SRCDIR)/Components/Fetch.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/Scoreboard.o : $(PIPELINE_MODEL_SRCDIR)/Components/Scoreboard.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
$(BUILD_DIR)/Write.o : $(PIPELINE_MODEL_SRCDIR)/Components/Write.cpp
$(CXX) $(CXXFLAGS) $^ -o [email protected]
.PHONY: clean
clean:
@rm -rf $(BUILD_DIR)/*.o $(BUILD_DIR)/*.so
你看到[這](https://stackoverflow.com/questions/14140570/llvm-os-x-symbols-not-found-換架構的x86-64編譯錯誤)? –
不確定這裏是否重要,但請注意您正在查看的文檔非常陳舊(2.6版在2009年發佈)。你的makefile說你在用3.8。 –
@StanislavPankevich剛看到它..我不知道如何使用llvm-config。我試圖遵循llvm.org網站上的文檔,但仍有疑問。 –