用于编译CUDA C的Makefile

时间:2015-12-01 22:20:21

标签: c cuda makefile

我用于C项目的标准目录结构如下,

root
  Makefile
src
  *.c
includes
  *.h
obj
 *.o
bin
 executable generated

我试图为CUDA C项目复制相同内容,这是我编写的Makefile,但我想我没有将链接部分更正,因为它正在运行一系列的错误。

    TARGET = bfs


    GCC = nvcc
    CUDA_INSTALL_PATH := /usr/local/cuda
    LIB := -I. -I$(CUDA_INSTALL_PATH)/include
    CUDA_LIBS := -L$(CUDA_INSTALL_PATH)/lib -lcudart

    SRCDIR = src
    OBJDIR = obj
    BINDIR = bin
    INClDIR = includes

    SOURCES := $(wildcard $(SRCDIR)/*.cu)
    INCLUDES := $(wildcard $(INClDIR)/*.h)
    OBJECTS := $(SOURCES : $(SRCDIR)/%.cu=$(OBJDIR)/%.cu)
    rm = rm -f

    $(BINDIR)/$(TARGET): $(OBJECTS)
        mkdir -p $(BINDIR)
        @$(GCC) $@ $(LIBS) -c $(OBJECTS)
        @echo "Linking complete!"

    $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cu
        @$(GCC) $(LIB) -c *.cu -o $@
        @echo "Compiled "$<" successfully!"

    .PHONEY: clean
    clean:
            @$(rm)   $(OBJECTS)
            @echo "Cleanup complete!"
    remove: clean
        @$(rm) $(BINDIR)/$(TARGET)
        @echo "Executable removed!"

我基本上用.cu文件替换src目录而不是.c并链接到我的Mac上的CUDA库。这是我得到的错误

mkdir -p bin
nvcc fatal   : Don't know what to do with 'bin/bfs'
make: *** [bin/bfs] Error 1

有人可以帮助我做到这一点。

0 个答案:

没有答案