kelson
November 30, 2010, 10:27am
1
Hi, I’m developping a a project on CUDA. I’m facing a “multiple definition” error.
I gathered all the global variables and kernels inside a header file and
include this header file into each test program. The skeleton is like this
//variable header
#ifnedef V_HEADER_H
#define V_HEADER_H
__global__ void kernel1();
__global__ void kernel2();
__global__ void kernel3();
int a, b, c;
float *fa, *fb,*fc;
#endif
//test program1
#include"vheader.h"
int test1()
{
..
}
//test program2
#include"vheader.h"
int test2()
{
..
}
//test program3
#include"vheader.h"
int test3()
{
..
}
Any help will be welcome.
Thank you
avidday
November 30, 2010, 10:41am
2
Is this a linking error or a compilation error and what exactly is it that is defined multiple times?
kelson
November 30, 2010, 10:51am
3
Thank you for your fast reply.
This happen during the compilation.
I got something like this:
obj/x86_64/test1.cu.o(.bss+0x178): Multiple definition of a
.
avidday
November 30, 2010, 11:03am
4
This happen during the compilation.
I got something like this:
obj/x86_64/test1.cu.o(.bss+0x178): Multiple definition of a
.
That error is occuring during linking, not compilation. You might want to read up on the use of [font=“Courier New”]static[/font] and [font=“Courier New”]extern[/font] storage declarations in C++. This doesn’t really have anything to do with CUDA, per se .