GCC查找.o文件
考虑下面的MakefileGCC查找.o文件,gcc,makefile,Gcc,Makefile,考虑下面的Makefile include ../../common/make.config CC = gcc CC_FLAGS = -g -fopenmp -O2 NVCC = $(CUDA_DIR)/bin/nvcc NVCC_FLAGS = -I$(CUDA_DIR)/include # 'make dbg=1' enables NVCC debugging ifeq ($(dbg),1) NVCC_FLAGS += -g -O0 else NVCC_FL
include ../../common/make.config
CC = gcc
CC_FLAGS = -g -fopenmp -O2
NVCC = $(CUDA_DIR)/bin/nvcc
NVCC_FLAGS = -I$(CUDA_DIR)/include
# 'make dbg=1' enables NVCC debugging
ifeq ($(dbg),1)
NVCC_FLAGS += -g -O0
else
NVCC_FLAGS += -O2
endif
# 'make emu=1' compiles the CUDA kernels for emulation
ifeq ($(emu),1)
NVCC_FLAGS += -deviceemu
endif
kmeans: cluster.o getopt.o kmeans.o kmeans_clustering.o kmeans_cuda.o rmse.o
$(CC) $(CC_FLAGS) cluster.o getopt.o kmeans.o kmeans_clustering.o kmeans_cuda.o rmse.o -o kmeans -L$(CUDA_LIB_DIR) -lcuda -lcudart -lm
%.o: %.[ch]
$(CC) $(CC_FLAGS) $< -c
kmeans_cuda.o: kmeans_cuda.cu
$(NVCC) $(NVCC_FLAGS) -c kmeans_cuda.cu
clean:
rm -f *.o *~ kmeans kmeans_cuda.linkinfo
这些文件是
$ ls
cluster.c getopt.c getopt.o kmeans_clustering.c kmeans_cuda.cu kmeans_cuda.o kmeans.h.gch Makefile_nvidia rmse.c run
cluster.o getopt.h kmeans.c kmeans_clustering.o kmeans_cuda_kernel.cu kmeans.h Makefile README rmse.o unistd.h
虽然有kmeans.c
,但我想知道为什么没有kmeans.o
,因此它无法在下一步链接目标文件
有没有办法解决这个问题?考虑一下规则
%.o: %.[ch]
$(CC) $(CC_FLAGS) $< -c
内置变量$
%.o: %.[ch]
$(CC) $(CC_FLAGS) $< -c
kmeans.o: kmeans.h kmeans.c
$(CC) $(CC_FLAGS) $< -c
gcc -g -fopenmp -O2 kmeans.h -c
%.o: %.c %.h
$(CC) $(CC_FLAGS) $< -c