我有幾個.cpp文件和幾個.h文件。如果我使用nvcc而不是g ++編譯它們,一切都很好。現在,當我開始(在main.cpp中)分配設備上的內存時,即CUDA無效int2的重新聲明
cudaMalloc((void**)&_a, _DSIZE * sizeof(float))
然後問題就開始了。我試圖改變擴展到.cu,但它甚至更糟。
錯誤,我得到:
mylib.h(39): error: invalid redeclaration of type name "int2" /usr/local/cuda/bin/../include/vector_types.h(402): here
mylib.h(43): error: invalid redeclaration of type name "int3" /usr/local/cuda/bin/../include/vector_types.h(406): here
mylib.h(47): error: invalid redeclaration of type name "float3" /usr/local/cuda/bin/../include/vector_types.h(434): here
顯然,INT2,INT3,FLOAT3等都是我自己再聲明這是位於mylib.h文件,是全球性的。
我也得到很多的警告:
mylib.h(128): warning: use of a type with no linkage to declare a function
mylib.h(129): warning: use of a type with no linkage to declare a function
我在做什麼錯?我一直努力與.CU文件,但我認爲這是不是真的有必要該擴展...
重新定義,警告關閉,但仍然是一個錯誤:
在/ usr/bin中/ LD:FSPB_kernel_Jelen的.o:在第`的.text」 FSPB_kernel_Jelen.o偏移0xa0100壞RELOC符號索引(0×90> = 0X1E)爲:不能讀取的符號:壞值 collect2:LD返回1個退出狀態 化妝:* [FSPB ]錯誤1
任何想法?
請顯示int2的聲明/定義等 – 2011-06-16 14:10:25
typedef struct { int x,y; } int2; typedef struct { int x,y,z; } int3; – Manolete 2011-06-16 14:22:37