GNU Make v。2.4.1
MacOS High Sierra
使用clang编译可执行文件
我的make文件有一个特殊的问题。我将CodeLite IDE生成的make文件与成功用于编译要添加功能的C库的make文件进行了拼接。我在库中包装了一些代码,以制作可执行的测试文件。我已经成功地编译了它直到昨天。我相信我所做的唯一区别是添加了“ $(OtherFlags)”来正确设置标志。现在,即使我删除了此添加项,make也不起作用。我得到了错误
'Debug / iceemdan-clang'不需要创建目标'Debug / main.c.o'的规则。停止。
这是由makefile的93行产生的
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(Libpath) $(Libs) $(IncludeSwitch) $(IncludePath) $(OtherFlags)
这是上下文之外的胡言乱语,如下所示(底部注释掉的代码来自原始makefile)
##
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased
##
## Debug
ProjectName :=iceemdan-clang
ConfigurationName :=Debug
WorkspacePath :=/Users/Common/iceemdan-dev/iceemdan-dev
ProjectPath :=/Users/Common/iceemdan-dev/iceemdan-dev/iceemdan-clang
IntermediateDirectory :=./Debug
OutDir := $(IntermediateDirectory)
CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=Coleman Family
Date :=08/08/2018
CodeLitePath :="/Users/Common/Library/Application Support/CodeLite"
LinkerName :=clang
SharedObjectLinkerName :=clang -shared -fPIC
ObjectSuffix :=.o
DependSuffix :=
PreprocessSuffix :=.o.i
DebugSwitch :=-gstab
IncludeSwitch :=-I
LibrarySwitch :=-l
OutputSwitch :=-o
LibraryPathSwitch :=-L
PreprocessorSwitch :=-D
SourceSwitch :=-c
OutputFile :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors :=
ObjectSwitch :=-o
ArchiveOutputSwitch :=
PreprocessOnlySwitch :=-E
ObjectsFileList :="iceemdan-clang.txt"
PCHCompileFlags :=
MakeDirCommand :=mkdir -p
LinkOptions :=
IncludePath := /opt/local/include
IncludePCH :=
RcIncludePath :=
Libs := -lgsl -lgslcblas -lm
ArLibs :=
LibPath := $(LibraryPathSwitch) /opt/local/lib
OtherFlags :=-DHAVE_INLINE -Wall -Wextra -std=c99 -pedantic -Wno-unknown-pragmas -Wshadow -Wpointer-arith -DCLANG
##
## Common variables
## AR, CXX, CC, AS, CXXFLAGS and CFLAGS can be overriden using an environment variables
##
AR := ar rcus
CXX := clang++
CC := clang
CXXFLAGS := -g -O0 -Wall $(Preprocessors)
CFLAGS := $(commonflags) $< -fPIC -shared -Wl $@ $(gsl_flags) -o $@ $(Preprocessors)
ASFLAGS :=
AS := llvm-as
##
## User defined environment variables
##
CodeLiteDir:=/Applications/codelite.app/Contents/SharedSupport/
PATH:=/Users/Common/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/opt/local/include
Srcs=main.c
Objects0=$(IntermediateDirectory)/main.c$(ObjectSuffix)
Objects=$(Objects0)
##
## Main Build Targets
##
.PHONY: all clean PreBuild PrePreBuild PostBuild MakeIntermediateDirs
all: $(OutputFile)
PreBuild:
@echo Executing Pre Build commands ...
$(eval gsl_flags = -L/opt/local/lib -lgsl -lgslcblas -lm -I/opt/local/include -DHAVE_INLINE)
$(eval commonflags := -Wall -Wextra -std=c99 -pedantic -Wno-unknown-pragmas -Wshadow -Wpointer-arith)
# $(eval commonflags += $(CFLAGS))
# $(eval commonflags += -g -DEEMD_DEBUG=0)
$(eval commonflags += -DCLANG)
$(eval PREFIX ?= /usr)
@echo Done
$(OutputFile): $(IntermediateDirectory)/.d $(Objects)
@$(MakeDirCommand) $(@D)
@echo "" > $(IntermediateDirectory)/.d
@echo $(Objects0) > $(ObjectsFileList)
$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(Libpath) $(Libs) $(IncludeSwitch) $(IncludePath) $(OtherFlags)
# clang $(gsl_flags) $(commonflags) -o ./Debug/main.c.o
MakeIntermediateDirs:
@test -d ./Debug || $(MakeDirCommand) ./Debug
$(IntermediateDirectory)/.d:
@test -d ./Debug || $(MakeDirCommand) ./Debug
#PreBuild:
# all
#Debug/main.c.o: main.c
#src/eemd.h | Debug
# clang $(commonflags) -c $< $(gsl_flags) -o $@
#Debug/main.c.a: Debug/main.c.o
# $(AR) rcs $@ $^
#eemd: main.c src/eemd.h
# clang $(commonflags) $< -fPIC -shared -Wl, ,$@ $(gsl_flags) -o $@
抱怨的是即使存在main.c,也无法构建main.c.o。 main -d似乎表明它正在搜索main.c. *,但没有费心去寻找main.c本身。
使用词干“ main.c”的尝试模式规则。
这在几个不同的目录中多次发生。我看到类似的回复
拒绝不可能的隐式先决条件'Debug / main.c.l'。
我从未见过尝试找到main.c的尝试。
答案 0 :(得分:0)
您的中间体应该称为main.o
,而不是main.c.o
。问题可能在这里:
Objects0=$(IntermediateDirectory)/main.c$(ObjectSuffix)
应该是
Objects0=$(IntermediateDirectory)/main$(ObjectSuffix)
我认为...