我是OS X上的新手开发人员。当我使用Makefile编译项目时,有一个我无法解决的错误。 但是我可以在Ubuntu16.04上成功运行这个项目,但是当我把它移到Mac上时却没有。
这是终端打印:
currychen-MC1:llvm-clang-iMac currychen$ make
g++ -I/usr/include -fno-rtti -O0 -g `/Users/currychen/llvm/llvm3.8-binaries/bin/llvm-config --cxxflags` -I/Users/currychen/llvm/tools/clang/include -I/Users/currychen/llvm/llvm3.8-binaries/tools/clang/include src_clang/rewritersample.cp -lclangAST -lclangAnalysis -lclangBasic -lclangDriver -lclangEdit -lclangFrontend -lclangFrontendTool -lclangLex -lclangParse -lclangSema -lclangEdit -lclangASTMatchers -lclangRewrite -lclangRewriteFrontend -lclangStaticAnalyzerFrontend -lclangStaticAnalyzerCheckers -lclangStaticAnalyzerCore -lclangSerialization -lclangToolingCore -lclangTooling `/Users/currychen/llvm/llvm3.8-binaries/bin/llvm-config --ldflags --libs --system-libs` -o build/rewritersample
clang: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk'
ld: library not found for -lcurses
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build/rewritersample] Error 1"
我的Makefile是
LLVM_SRC_PATH := /Users/currychen/llvm
LLVM_BUILD_PATH := /Users/currychen/llvm/llvm3.8-binaries
LLVM_BIN_PATH := $(LLVM_BUILD_PATH)/bin
CXX := g++ -I/usr/include
CXXFLAGS := -fno-rtti -O0 -g
LLVM_CXXFLAGS := `$(LLVM_BIN_PATH)/llvm-config --cxxflags`
LLVM_LDFLAGS := `$(LLVM_BIN_PATH)/llvm-config --ldflags --libs --system-libs`
LLVM_LDFLAGS_NOLIBS := `$(LLVM_BIN_PATH)/llvm-config --ldflags`
CLANG_INCLUDES := \
-I$(LLVM_SRC_PATH)/tools/clang/include \
-I$(LLVM_BUILD_PATH)/tools/clang/include
CLANG_LIBS := \
-lclangAST \
-lclangAnalysis \
-lclangBasic \
-lclangDriver \
-lclangEdit \
-lclangFrontend \
-lclangFrontendTool \
-lclangLex \
-lclangParse \
-lclangSema \
-lclangEdit \
-lclangASTMatchers \
-lclangRewrite \
-lclangRewriteFrontend \
-lclangStaticAnalyzerFrontend \
-lclangStaticAnalyzerCheckers \
-lclangStaticAnalyzerCore \
-lclangSerialization \
-lclangToolingCore \
-lclangTooling
SRC_CLANG_DIR := src_clang
BUILDDIR := build
$(BUILDDIR)/rewritersample: $(SRC_CLANG_DIR)/rewritersample.cp
$(CXX) $(CXXFLAGS) $(LLVM_CXXFLAGS) $(CLANG_INCLUDES) $^ $(CLANG_LIBS) $(LLVM_LDFLAGS) -o $@
.PHONY: clean
clean:
-rm -rf $(BUILDDIR)/*
答案 0 :(得分:0)
感谢@Jonathan Leffler和@Carl Norum。 添加-v对我来说非常有用,可以看到真正使用了哪些标志。 最后我还在g ++中添加-L以使编译器知道lib的位置。 因此,如果您已经安装了libXXX,则应指定dir以使编译器知道。