makefile“没有规则可以成为目标"错误 [英] makefile "no rule to make a target" error
问题描述
我已经研究这个问题一段时间了,但仍然不知道出什么问题.
I have been looking at this problem for a while and still don't know what is wrong.
我的makefile如下:
My makefile looks like:
F90 = pgf90
NETCDF_DIR = /opt/netcdf
LBS = -L$(NETCDF_DIR)/lib -lnetcdff -lnetcdf
INCLUDE_MODULES = -I$(NETCDF_DIR)/include
EXEC = CNG_WRFCHEM_EMI
OBJS = module_CNG_WRFCHEM_EMI_lib.o \
CNG_WRFCHEM_EMI.o
${EXEC} : ${OBJS}
${F90} -o $@ ${OBJS} ${LIBS}
.f90.o:
${F90} -c ${INCLUDE_MODULES} $<
clean:
rm -f ${EXEC} ${OBJS} *.mod
错误消息是:
make: *** No rule to make target `module_CNG_WRFCHEM_EMI_lib.o', needed by `CNG_WRFCHEM_EMI'. Stop.
所有文件都与图片所示在同一目录中
All the files are in the same directory as the picture shows:
谢谢
推荐答案
Make不知道.f90
是后缀,因此您的后缀规则无效.如果make不知道后缀规则,仅声明后缀规则是不够的.如果要使用后缀规则,还必须添加带有.SUFFIXES
伪目标的新后缀,如下所示:
Make doesn't know that .f90
is a suffix, so your suffix rule is not valid. It's not enough to just declare a suffix rule if make doesn't know about the suffix. If you want to use suffix rules, you also have to add the new suffix with the .SUFFIXES
pseudo-target, like this:
.SUFFIXES: .f90
或者您可以使用不需要的模式规则(但特定于GNU make):
Or you can use pattern rules, which don't require this (but are GNU make-specific):
%.o : %.f90
${F90} -c ${INCLUDE_MODULES} $<
这篇关于makefile“没有规则可以成为目标"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!