Cuda错误:函数已在另一个.cu.obj文件中定义 [英] Cuda error: function has already been defined in another .cu.obj file

查看:1253
本文介绍了Cuda错误:函数已在另一个.cu.obj文件中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编译一个有人送给我的cuda项目。虽然编译阶段通过,链接阶段失败。下面是错误的示例:

 错误298错误LNK2005:int __cdecl compare_ints(void const *,void const *) 已经在3level_1.cu.obj decode_p4.cu.obj中定义的(?compare_ints @@ YAHPBX0 @ Z)

基本上,文件decode_p4.cu.obj抱怨函数compare_ints已经在3level_1.cu.obj中定义。有关如何避免此行为的任何想法?



以下是类似错误的列表,如果这有助于:

 错误384错误LNK2005:int __cdecl compare_ints(void const *,void const *)(?compare_ints @@ YAHPBX0 @ Z)已经在3level_1.cu.obj decode_p4.cu.obj god 
错误385错误LNK2005:int __cdecl cpu_intersection(unsigned int *,int,unsigned int *,int)(?cpu_intersection @@ YAHPAIH0H @ Z)已经在3level_1.cu.obj decode_p4.cu.obj god
错误386错误LNK2005:int __cdecl intersection_cpu(unsigned int * * const,int * const,int)(?intersection_cpu @@ YAHQAPAIQAHH @ Z)已经在3level_1.cu.obj decode_p4.cu.obj god
错误387错误LNK2005:void __cdecl sort_it(unsigned int * * const,int * const,int)(?sort_it @@ YAXQAPAIQAHH @ Z)已经在3level_1.cu.obj decode_p4.cu.obj god
错误388错误LNK2005:int __cdecl GPU_Intersection(unsigned int * * const,int * const,int,unsigned int *,unsigned int *,unsigned int *,struct uint4 *)(?GPU_Intersection @@ YAHQAPAIQAHHPAI22PAUuint4 @@@ Z)已经在3level_1.cu.obj中定义decode_p4.cu.obj god
错误389错误LNK2005:int __cdecl ceilPow2(int)(?ceilPow2 @@ YAHH @ Z)已在3level_1中定义。 cu.obj decode_p4.cu.obj god
错误390错误LNK2005:已在3level_1.cu.obj decode_p4.cu.obj中定义的void __cdecl recAllocate1(int,int)(?recAllocate1 @@ YAXHH @ Z) god
错误391错误LNK2005:unsigned int __cdecl getceilPow2(unsigned int)(?getceilPow2 @@ YAII @ Z)已在3level_1.cu.obj中定义decode_p4.cu.obj god
错误392错误LNK2005:void __cdecl runTest(int,char * *)(?runTest @@ YAXHPAPAD @ Z)已经定义在3level_1.cu.obj decode_p4.cu.obj god
错误393错误LNK2005:void __cdecl __device_stub__Z13scanBlockMAX1P5uint4S0_Pj已经定义在3level_1.cu.obj中的定义的变量(struct uint4 *,struct uint4 *,unsigned int *)(?__ device_stub__Z13scanBlockMAX1P5uint4S0_Pj @@ YAXPAUuint4 @@ 0PAI @ Z)god
错误394错误LNK2005: void __cdecl scanBlockMAX1(struct uint4 *,struct uint4 *,unsigned int *)(?scanBlockMAX1 @@ YAXPAUuint4 @@ 0PAI @ Z)已经在3level_1.cu.obj中定义decode_p4.cu.obj god
错误395错误已经在3level_1.cu.obj中定义的LNK2005:void __cdecl __device_stub__Z16scanBlockMAX1_gpP5uint4S0_Pj(struct uint4 *,struct uint4 *,unsigned int *)(?__ device_stub__Z16scanBlockMAX1_gpP5uint4S0_Pj @@ YAAPAUuint4)

这只是一个猜测,但如果这是视觉工作室,我' ve看到这种情况之前,当代码是在#included的.cu文件。在这种情况下,它也不应该被编译为源文件。要避免这种情况,请右键点击其中一个文件(很难区分您的说明),然后选择属性,然后找到并选中从构建中排除复选框。


I am trying to compile a cuda project that someone sent me. Though the compile stage passes, the link stage is failing. Below is an example of the error:

Error   298 error LNK2005: "int __cdecl compare_ints(void const *,void const *)" (?compare_ints@@YAHPBX0@Z) already defined in 3level_1.cu.obj  decode_p4.cu.obj    

Basically, the file decode_p4.cu.obj is complaining that the function compare_ints is already defined in 3level_1.cu.obj. Any ideas on how to avoid this behaviour?

Below is a list of similar errors if that helps:

Error   384 error LNK2005: "int __cdecl compare_ints(void const *,void const *)" (?compare_ints@@YAHPBX0@Z) 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)" (?cpu_intersection@@YAHPAIH0H@Z) 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)" (?intersection_cpu@@YAHQAPAIQAHH@Z) 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)" (?sort_it@@YAXQAPAIQAHH@Z) 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 *)" (?GPU_Intersection@@YAHQAPAIQAHHPAI22PAUuint4@@@Z) already defined in 3level_1.cu.obj decode_p4.cu.obj    god
Error   389 error LNK2005: "int __cdecl ceilPow2(int)" (?ceilPow2@@YAHH@Z) already defined in 3level_1.cu.obj   decode_p4.cu.obj    god
Error   390 error LNK2005: "void __cdecl recAllocate1(int,int)" (?recAllocate1@@YAXHH@Z) already defined in 3level_1.cu.obj decode_p4.cu.obj    god
Error   391 error LNK2005: "unsigned int __cdecl getceilPow2(unsigned int)" (?getceilPow2@@YAII@Z) already defined in 3level_1.cu.obj   decode_p4.cu.obj    god
Error   392 error LNK2005: "void __cdecl runTest(int,char * *)" (?runTest@@YAXHPAPAD@Z) 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 *)" (?__device_stub__Z13scanBlockMAX1P5uint4S0_Pj@@YAXPAUuint4@@0PAI@Z) 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 *)" (?scanBlockMAX1@@YAXPAUuint4@@0PAI@Z) 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@@YAXPAUuint4@@0PAI@Z) already defined in 3level_1.cu.obj    decode_p4.cu.obj    god

解决方案

This is just a guess, but if this is visual studio, I've seen this case before when the code is in a .cu file that is #included. In that case it should not also be compiled as a source file. To avoid this, right click on one of the files (hard to tell which from your description) and select properties, and then find and check the "exclude from build" check box.

这篇关于Cuda错误:函数已在另一个.cu.obj文件中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆