2011-07-11 30 views
1

誰かが私に送るcudaプロジェクトをコンパイルしようとしています。コンパイル段階が終了しても、リンクステージは失敗しています。Cudaエラー:別の.cu.objファイルに関数が既に定義されています

Error 298 error LNK2005: "int __cdecl compare_ints(void const *,void const *)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj  

基本的には、ファイルdecode_p4.cu.objは関数compare_intsが既に3level_1.cu.objで定義されていることを不平を言っている:以下はエラーの例です。どのようにこの動作を回避するための任意のアイデア?

以下

ことができます場合にも、同様のエラーのリストです:

Error 384 error LNK2005: "int __cdecl compare_ints(void const *,void const *)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 385 error LNK2005: "int __cdecl cpu_intersection(unsigned int *,int,unsigned int *,int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 386 error LNK2005: "int __cdecl intersection_cpu(unsigned int * * const,int * const,int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 387 error LNK2005: "void __cdecl sort_it(unsigned int * * const,int * const,int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 388 error LNK2005: "int __cdecl GPU_Intersection(unsigned int * * const,int * const,int,unsigned int *,unsigned int *,unsigned int *,struct uint4 *)" ([email protected]@[email protected]@@Z) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 389 error LNK2005: "int __cdecl ceilPow2(int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 390 error LNK2005: "void __cdecl recAllocate1(int,int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 391 error LNK2005: "unsigned int __cdecl getceilPow2(unsigned int)" ([email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 392 error LNK2005: "void __cdecl runTest(int,char * *)" ([email protected]@YAXHPAP[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 393 error LNK2005: "void __cdecl __device_stub__Z13scanBlockMAX1P5uint4S0_Pj(struct uint4 *,struct uint4 *,unsigned int *)" ([email protected]@[email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 394 error LNK2005: "void __cdecl scanBlockMAX1(struct uint4 *,struct uint4 *,unsigned int *)" ([email protected]@[email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
Error 395 error LNK2005: "void __cdecl __device_stub__Z16scanBlockMAX1_gpP5uint4S0_Pj(struct uint4 *,struct uint4 *,unsigned int *)" (?__device_stub__Z16scanBlockMAX1_gpP5uint4S0_Pj@@[email protected]@[email protected]) already defined in 3level_1.cu.obj decode_p4.cu.obj god 
+0

人は、これで私を助けてください。私はできるだけ早くこれを行う必要があります – Programmer

答えて

8

は、これは単なる推測ですが、これはVisual Studioのであれば、私はコードが.cuのときに前にこのケースを見てきました#includeされたファイル。その場合、ソースファイルとしてコンパイルするべきではありません。これを避けるには、ファイルの1つを右クリックして(説明からわかりにくい)、プロパティを選択してから、[ビルドから除外]チェックボックスを探してチェックします。

+0

あなたに私に答えを教えるために必要なその他の情報 – Programmer

+0

あなたの解決策を試してみてください。問題を解決しないでください:( – Programmer

+1

ビルドからファイルを除外(inckuded)してくれてありがとう、ありがとう。 – Alleo

0

あなたのdecode_p4.cu 3level_1.cuのように見えますが、これらの機能は複数のものを含んでおり、これらの機能を定義するファイルに焦点を当てています。

宣言を.cuhファイル(cのheadファイルと同じ)に入れ、cuファイルの代わりにcuhをインクルードしてから、include guardsをチェックアウトしてください。

Good Luck、Bro!

0

複数のファイルで同じ問題が発生していたため、複数の定義の問題は通常alaをガードすることで処理されるため、混乱していました。働いていた何

# ifndef Function_name_Guard 
#define Function_name 
your code 
#endef % Function_name_Guard 

代わり.cuファイルを省略し、本体のみファイルを保持することでした。