У меня возникли проблемы с ошибкой «Ошибка связи LNK2005 ... уже определена». Файлы являются следующие:Ошибка связи LNK2005 несколько файлов CUDA
// File Bitmap4.cu
#include "Bitmap4.h" // header
#include "Bitmaps_cuda.h" // header with just the definitions of the kernels
..... // I call 3+2 kernel functions (3 in one method, 1 in another and 1 in another one)
Тогда у меня есть этот один:
// File Bitmap8.cu
#include "Bitmap8.h" // header
#include "Bitmaps_cuda.h" // the same as above
..... // I call 4 kernel functions (4 in the same method)
Тогда у меня есть заголовок ядра:
#ifndef __BITMAPS_KERNEL__
#define __BITMAPS_KERNEL__
...... // 9 kernels definitions
#endif
И, наконец, у меня есть один:
// File Bitmaps_cuda.h
#include <cuda.h>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
#include <device_functions.h>
#include <stdio.h>
// Inside here there all the kernel functions that the files
// Bitmap4.cu and Bitmap8.cu are using
Проблема в том, что, если я не знаю, t включают #include "Bitmaps_cuda.h" в одном из битов * .cu, конечно, компилятор скажет, что я пропустил определения функций ядер. Я прочитал много сообщений, и я уже включил «Дополнительные разрывы» и необходимые PATH. Проблемы начались, когда я добавил файл Bitmap8.cu с его относительными ядрами, потому что до этого приложение работало правильно.
Во всяком случае, те ошибки, которые у меня есть:
1>Bitmap8.cu.obj : error LNK2005: "void * __cdecl big_random_block(int([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "int * __cdecl big_random_block_int(int([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "unsigned char __cdecl value(float,float,int([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void * __cdecl start_thread(unsigned int(__stdcall*)(void *),void *)" ([email protected]@[email protected]@Z) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl end_thread(void *)"([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl destroy_thread(void *)"([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl wait_for_threads(void * const *,int)"([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl__device_stub__Z14float_to_colorPhPKf(unsigned char *,float const *)"([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl float_to_color(unsigned char *,float_const *)" ([email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl__device_stub__Z14float_to_colorP6uchar4PKf(struct uchar4 *,float const *)"([email protected]@[email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>Bitmap8.cu.obj : error LNK2005: "void __cdecl float_to_color(struct uchar4 *,float_const *)" ([email protected]@[email protected]@[email protected]) already defined in Bitmap4.cu.obj
1>C:\Users\dberdin\documents\visual studio 2010\Projects\gpuSPAM\Debug\gpuSPAM.exe : fatal error LNK1169: one or more multiply defined symbols found
Я пробовал разные решения, но с какими-либо результатами.
Спасибо заранее!
РЕДАКТИРОВАТЬ
На сайте (http://msdn.microsoft.com/en-us/library/72zdcz6f.aspx) я обнаружил, что одна из причин этих ошибок:
- Абсолютная определяется в два раза, с другим значением в каждом определении.
Ну, на самом деле, как я писал внизу, у меня есть такие разногласия, но я не могу поступить иначе. Любая идея, как его решить?
Еще раз спасибо заранее
Я включил файл заголовка дважды! Задача решена! – davideberdin