Multiple definition error

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;


//test program1 


int test1()




//test program2


int test2()




//test program3


int test3()




Any help will be welcome.

Thank you

Is this a linking error or a compilation error and what exactly is it that is defined multiple times?

Thank you for your fast reply.

This happen during the compilation.

I got something like this:

obj/x86_64/ 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.

Thank you very much.

I will do.