Ich habe einige Probleme mit dem Fehler "Link Fehler LNK2005 ... bereits definiert". Die Dateien sind wie folgt:Link Fehler LNK2005 mehrere CUDA Dateien
// 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)
Dann habe ich dieses:
// 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)
Dann habe ich den Kernel-Header:
#ifndef __BITMAPS_KERNEL__
#define __BITMAPS_KERNEL__
...... // 9 kernels definitions
#endif
Und schließlich, ich habe diese ein:
// 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
Das Problem ist, dass, wenn ich nicht ' t enthalten die #include "Bitmaps_cuda.h" in einem der Bitmap * .cu, natürlich, der Compiler wird sagen, dass ich die Definitionen der Kernel-Funktionen verpasst. Ich habe viele Posts gelesen und ich habe bereits die "zusätzlichen Abhängigkeiten" und die erforderlichen PATHs eingefügt. Die Probleme begannen, als ich die Datei Bitmap8.cu mit ihren relativen Kernen hinzufügte, weil vorher die Anwendung richtig funktionierte.
Wie auch immer, sind diejenigen, die Fehler, die ich habe:
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
ich verschiedene Lösungen versucht, aber mit allen Ergebnissen.
Vielen Dank im Voraus!
EDIT
Auf der Website (http://msdn.microsoft.com/en-us/library/72zdcz6f.aspx) fand ich, dass eine der Ursachen für diesen Fehler ist:
- Absoluter zweimal definiert ist, mit einem anderen Wert in jeder Definition.
Nun, eigentlich, wie ich unten geschrieben habe, habe ich diese Art von Definitionen, aber ich kann nicht anders machen. Irgendeine Idee, wie man es löst?
Vielen Dank noch einmal im Voraus
Ich habe eine Header-Datei zweimal enthalten! Problem gelöst! – davideberdin