【发布时间】:2022-01-16 01:59:42
【问题描述】:
我正在尝试制作子程序的目标文件。我遵循以下(https://unix.stackexchange.com/questions/585452/makefile-error-no-rule-to-make-target-how-to-solve-it、https://cs50.stackexchange.com/questions/10847/error-make-no-rule-to-make-target-mario-stop/10852)但无法修复错误。使用的make文件是:
ifndef PVFMM_DIR
PVFMM_DIR=./..
endif
-include $(PVFMM_DIR)/MakeVariables
ifndef CXX_PVFMM
$(error Cannot find file: MakeVariables)
endif
FC_PVMM = mpif90
FC = mpif90
FC=$(FC_PVFMM) # TODO: for now, FC must be provided by user
CC=$(CC_PVFMM) # TODO: for now, CC must be provided by user
CXX=$(CXX_PVFMM)
CXXFLAGS=$(CXXFLAGS_PVFMM)
LDLIBS=$(LDLIBS_PVFMM)
RM = rm -f
MKDIRS = mkdir -p
BINDIR = ./bin
SRCDIR = ./src
OBJDIR = ./obj
INCDIR = ./include
TARGET_BIN = \
$(OBJDIR)/example-f.o
all : example-f.o
example-f.o: $(SRCDIR)/%.f90
-@$(MKDIRS) $(dir $@)
@echo "here" $(dir $@)
$(PVFMM_DIR)/libtool --mode=link --tag=FC mpif90 $(CXXFLAGS) -I$(INCDIR) $^ $(LDLIBS) -c $@
我收到以下错误:
cd ./examples && make;
make[1]: Entering directory '/home/bidesh/Coding/FMM/pvfmm-develop/examples'
make[1]: *** No rule to make target 'src/%.f90', needed by 'example-f.o'. Stop.
make[1]: Leaving directory '/home/bidesh/Coding/FMM/pvfmm-develop/examples'
Makefile:1410: recipe for target 'all-examples' failed
make: *** [all-examples] Error 2
谁能告诉我我犯的错误?
我现在已将 make 文件更改为:
TARGET_BIN = \
$(OBJDIR)/example-f.o
all : $(TARGET_BIN)
$(OBJDIR)/%: $(SRCDIR)/%.f90
-@$(MKDIRS) $(dir $@)
@echo "here" $(dir $@)
$(PVFMM_DIR)/libtool --mode=link --tag=FC mpif90 $(CXXFLAGS) -I$(INCDIR) $^ $(LDLIBS) -c $@
并且example-f.f90子程序存在于src中。当我尝试编译时,我收到以下错误:
make[1]: Entering directory '/home/bidesh/Coding/FMM/pvfmm-develop/examples'
make[1]: *** No rule to make target 'obj/example-f.o', needed by 'all'. Stop.
make[1]: Leaving directory '/home/bidesh/Coding/FMM/pvfmm-develop/examples'
Makefile:1410: recipe for target 'all-examples' failed
make: *** [all-examples] Error 2
也许我犯了一些愚蠢的错误。我是 Makefile 和 Linux 环境的新手。我将被帮助了解错误。谢谢。
【问题讨论】:
标签: makefile compilation