"링크 오류 LNK2005 ... 이미 정의 됨"오류로 몇 가지 문제점이 있습니다.링크 오류 LNK2005 여러 CUDA 파일
// 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 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 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
문제는, 비트 맵 * .cu 중 하나에 #include "Bitmaps_cuda.h"을 포함 시키십시오. 물론 컴파일러는 커널 함수의 정의를 놓쳤다 고 말할 것입니다. 나는 많은 게시물을 읽었고 나는 이미 "추가의 직능들 (Dipendencies)"과 필요한 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 *)"(?destroy[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)에서
EDIT 나 그 오류의 원인 중 하나 인 것으로 나타났다.
글쎄, 사실, 내가 바닥에 쓴 것처럼, 나는 이런 종류의 결정을하지만, 나는 다르게 할 수 없다. 어떤 아이디어로 그것을 해결할 수 있을까요? 당신이 9 개 커널 선언이 아니라 정의를 가지고
헤더 파일을 두 번 포함했습니다. 문제 해결됨! – davideberdin