游.程 2018-11-11 13:18 采纳率: 0%
浏览 221

调试编译错误的多个定义

I have 3 CUDA files which I am trying to complile inside ./Obj/FILENAME.o and create ./run executable. I try it with this script:

IDIR   = ./
ODIR   = ./Obj/
SDIR   = ./
CFLAGS = -I $(IDIR)
NVCC   = nvcc
NVCCFLAGS   = $(CFLAGS) --ptxas-options=-v

_OBJ = File.o kmeans.o wtime.o
OBJ  = $(patsubst %, $(ODIR)%, $(_OBJ))

$(ODIR)%.o: $(SDIR)%.cu
    $(NVCC) -c -o $@ $< $(NVCCFLAGS) 

run: $(OBJ)
    $(NVCC) -o $@ $^ $(NVCCFLAGS)

.PHONY: clean
clean:
    rm -f $(ODIR)*.o *~ core $(INCDIR)/*~ run $(SDIR)*~

But I get title error, one screenshot of the complete output:

Error

The header file where I declare it is:

#ifndef _H_KMEANS
#define _H_KMEANS

#include <stdio.h>
#include <stdlib.h>
#include <string.h>     /* strtok() */
#include <sys/types.h>  /* open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>     /* getopt() */
#include <assert.h>
#include "File.h"
#include "wtime.h"

#define msg(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); } while (0)
#define err(format, ...) do { fprintf(stderr, format, ##__VA_ARGS__); exit(1); } while (0)
#define malloc2D(name, xDim, yDim, type) do {               \
    name = (type **)malloc(xDim * sizeof(type *));          \
    assert(name != NULL);                                   \
    name[0] = (type *)malloc(xDim * yDim * sizeof(type));   \
    assert(name[0] != NULL);                                \
    for (size_t i = 1; i < xDim; i++)                       \
        name[i] = name[i-1] + yDim;                         \
} while (0)

#ifdef __CUDACC__
inline void checkCuda(cudaError_t e) {
    if (e != cudaSuccess) {
        // cudaGetErrorString() isn't always very helpful. Look up the error
        // number in the cudaError enum in driver_types.h in the CUDA includes
        // directory for a better explanation.
        err("CUDA Error %d: %s\n", e, cudaGetErrorString(e));
    }
}

inline void checkLastCudaError() {
    checkCuda(cudaGetLastError());
}
#endif

float** kmeans(float**, int, int, int, float, int*, int*);

int         _debug;
extern int  _debug;

#endif

And this header is included in kmeans.cu and File.cu sources.

Anyone know why I get that error? Thank you.

转载于:https://stackoverflow.com/questions/53249128/multiple-definitions-of-debug-compiler-error

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 iOS 自定义输入法-第三方输入法
    • ¥15 很想要一个很好的答案或提示
    • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
    • ¥15 怀疑手机被监控,请问怎么解决和防止
    • ¥15 Qt下使用tcp获取数据的详细操作
    • ¥15 idea右下角设置编码是灰色的
    • ¥15 全志H618ROM新增分区
    • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
    • ¥15 NAO机器人的录音程序保存问题
    • ¥15 C#读写EXCEL文件,不同编译