Straight to the point:
I have the following file structure:
I compile this structure with the following makefile, with the command "make MODEL=mapB":
MODELDIR := ./$(MODEL)
MODULES := $(MODELDIR)
CFLAGS += -I. $(patsubst %,-I%,$(MODULES))
NVCFLAGS += -I. $(patsubst %,-I%,$(MODULES))
NVCC += nvcc
NVCFLAGS += -arch=sm_30 --ptxas-options=-O1
CFLAGS += -Wall -pedantic
LDLIBS += -lz -lpthread
CFLAGS += -g
SRCS += step.cu $(MODELDIR)/model.cu $(MODELDIR)/model_init.c \
main.c
OBJS += step.o $(MODELDIR)/model.o $(MODELDIR)/model_init.o
all: .depend runmodel
dims.h: gen_dims.sh
./gen_dims.sh 1024 1024
runmodel: ${OBJS} main.o
${NVCC} ${NVCFLAGS} ${LDLIBS} $^ -o $@
%.o: %.cu
${NVCC} ${NVCFLAGS} -dc $<
.PHONY: depend clean test
depend:
${NVCC} ${NVCFLAGS} -M ${SRCS} > .depend
.depend: ${SRCS} makefile dims.h
${NVCC} ${NVCFLAGS} -M ${SRCS} > .depend
clean:
${RM} ${OBJS} runmodel compare *.cmo *.cmx *.cmi *.o
include .depend
This gives an nvlink error, namely " nvlink fatal : Could not open input file 'mapB/model.o "
I looked at where the .o files are placed and my file structure with the .o-files generated with this makefile looks like:
Is there anybody that has an idea as to why the model.o file appears in the upper directory instead of in the subfolder, which makes that later on in the compilation process it cannot be found?
A solution to resolve this issue would also be welcomed.
I don't have nvcc to play with, so I can't be sure, but I suggest you try this, and tell us the result:
%.o: %.cu
${NVCC} ${NVCFLAGS} -dc $< -o $@