“*** target pattern contains no '%'. stop.”

机子老了,实在是上不了VS。网上溜了一圈后下了个 codelite 试试,占资源不多,代码补全挺不错的。

可是昨晚更改了一个工程的一点设置之后编译就通不过了,无论是Build,Rebuild还是 Clean都是这个错误信息。

test.mk:72: *** target pattern contains no '%'.  Stop.

单词倒是都认识,可连在一起的意思就丈二和尚摸不到头脑了。从后缀名.mk猜测估计是卡在make这里了。看来这次make是跟我过不去了。Google了一下,信息少得可怜。之前有2人也碰到同样的错误信息,说法有二:1、make版本问题,3.8.0以后对windows文件名支持有问题;2、还是路径名中用了中文字符惹的祸。可是都与我的状况不同啊。路径名尽量不使用中文这我是知道的,进一步的我连路径名中的空格下划线的使用也很小心,再三检查路径名没任何问题。

没办法,硬着头皮啃啃看吧。晕!我对makefile可是连四分之一桶水都没有啊。拆开test.mk来看,文件是 Codelite 自动生成的,这个工程只是试验,内容不多。

##
## Auto Generated makefile by CodeLite IDE
## any manual changes will be erased      
##
## Debug
ProjectName            :=test
ConfigurationName      :=Debug
WorkspacePath          := "E:\Experiment"
ProjectPath            := "E:\Experiment\test"
IntermediateDirectory  :=$(WorkspacePath)/$(ConfigurationName)
OutDir                 := $(IntermediateDirectory)
CurrentFileName        :=
CurrentFilePath        :=
CurrentFileFullPath    :=
User                   :=lwouyang
Date                   :=2013-3-24
CodeLitePath           :="E:\CodeLite"
LinkerName             :=gcc
SharedObjectLinkerName :=gcc -shared -fPIC
ObjectSuffix           :=.o
DependSuffix           :=.o.d
PreprocessSuffix       :=.o.i
DebugSwitch            :=-g 
IncludeSwitch          :=-I
LibrarySwitch          :=-l
OutputSwitch           :=-o 
LibraryPathSwitch      :=-L
PreprocessorSwitch     :=-D
SourceSwitch           :=-c 
OutputFile             :=$(IntermediateDirectory)/$(ProjectName)
Preprocessors          :=
ObjectSwitch           :=-o 
ArchiveOutputSwitch    := 
PreprocessOnlySwitch   :=-E 
ObjectsFileList        :="test.txt"
PCHCompileFlags        :=
MakeDirCommand         :=makedir
RcCmpOptions           := 
RcCompilerName         :=windres
LinkOptions            :=  
IncludePath            :=  $(IncludeSwitch). $(IncludeSwitch). 
IncludePCH             := 
RcIncludePath          := 
Libs                   := 
ArLibs                 :=  
LibPath                := $(LibraryPathSwitch). 

##
## Common variables
## AR, CXX, CC, CXXFLAGS and CFLAGS can be overriden using an environment variables
##
AR       := ar rcus
CXX      := gcc
CC       := gcc
CXXFLAGS :=  -g -O0 -Wall $(Preprocessors)
CFLAGS   :=  -g -O0 -Wall $(Preprocessors)


##
## User defined environment variables
##
CodeLiteDir:=E:\CodeLite
UNIT_TEST_PP_SRC_DIR:=E:\UnitTest++
Objects0=$(IntermediateDirectory)/main$(ObjectSuffix) 

Objects=$(Objects0) 

##
## Main Build Targets 
##
.PHONY: all clean PreBuild PrePreBuild PostBuild
all: $(OutputFile)

$(OutputFile): $(IntermediateDirectory)/.d $(Objects) 
	@$(MakeDirCommand) $(@D)
	@echo "" > $(IntermediateDirectory)/.d
	@echo $(Objects0)  > $(ObjectsFileList)
	$(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)

$(IntermediateDirectory)/.d:
	@$(MakeDirCommand) "$(WorkspacePath)/$(ConfigurationName)"

PreBuild:


##
## Objects
##
$(IntermediateDirectory)/main$(ObjectSuffix): main.c $(IntermediateDirectory)/main$(DependSuffix)
	$(CC) $(SourceSwitch) "E:/Experiment/test/main.c" $(CFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/main$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/main$(DependSuffix): main.c
	@$(CC) $(CFLAGS) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/main$(ObjectSuffix) -MF$(IntermediateDirectory)/main$(DependSuffix) -MM "main.c"

$(IntermediateDirectory)/main$(PreprocessSuffix): main.c
	@$(CC) $(CFLAGS) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/main$(PreprocessSuffix) "main.c"


-include $(IntermediateDirectory)/*$(DependSuffix)
##
## Clean
##
clean:
	$(RM) $(IntermediateDirectory)/main$(ObjectSuffix)
	$(RM) $(IntermediateDirectory)/main$(DependSuffix)
	$(RM) $(IntermediateDirectory)/main$(PreprocessSuffix)
	$(RM) $(OutputFile)
	$(RM) $(OutputFile).exe
	$(RM) "../.build-debug/test"

第72行是
all: $(OutputFile)
而$(OutputFile)依赖于$(IntermediateDirectory)。确实,我有改动过$(IntermediateDirectory),这个变量是中间目录,Codelite 将所有中间文件和生成文件都放在这个目录下边了。原来的值应该是./$(ConfigurationName)吧,因为我将多个工程放在在同一个工作区内,为了方便调试想生成时把这些都输出到同一个输出目录下,所以改成了$(WorkspacePath)/$(ConfigurationName)。将$(IntermediateDirectory)的值改回原来的值又可以编译了。嘿!找对方向了。仔细比对发现$(WorkspacePath)的值是"E:\Experiment\"已经自带了一个反斜杠,于是把多出来的斜杠去掉,改成$(WorkspacePath)$(ConfigurationName)。试了下,还是不行。莫非还真是路径支持有问题?这个MinGW自带的make程序版本是3.8.1。看到makefile最后一行的双点和联想到可以编译的$(IntermediateDirectory)的原来的值,说不定改成相对路径以避免windows盘符这种奇怪语法。我试着将其改为../../Experiment/$(ConfigurationName)。还别说,编译通过,这基本达到改动设置的初衷。只是这。。我无语。

但我终究还是气不过,自己又试了将$(IntermediateDirectory)改成不同的值的情况,其中E:/Experiment/$(ConfigurationName)也可以通过,另外我输入E:\Experiment\$(ConfigurationName)点完Apply的时候,Codelite自动将路径中的反斜杠改成了斜杠。看来罪魁祸首不是那些盘符斜杠下划线什么的,而是扩展$(WorkspacePath)时多出来的不起眼的双引号。

经过试验,路径中包含盘符和下划线都能够通过编译,但路径中有中文字符时出现乱码,对字符编码我无能为力但我可以不在路径中用中文字符。另外路径中包含空格也是不行的哦,因为make会把它分开成几个路径来看。

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值