Hi. I created a CUDA project in visual studio, with the typical CUDA Sample of adding 2 arrays (kernel.cu).
I want to try to call this Kernel.cu from a cpp file, but it gives me the next mistake
Error 1 error LNK2001: external symbol “void __cdecl kernel(void)” (?kernel@@YAXXZ) unresolved Test.obj VectorAdd
Error 2 fatal error LNK1120: 1 external unresolved
This is the code of my cpp
#include <stdio.h>
extern void kernel();
int main(int argc, char* argv )
{
printf(“HelloWorld”);
kernel();
return 0;
}
Thanks
Try using
extern "C" void kernel();
Still didn’t work :(
I’ve found this link with an example and I’m trying to make it work…I’ll notice if I make some progress :)
http://www.macs.hw.ac.uk/~wl145/CUDA%20Examples/1_C++%20wrapper%20around%20CUDA.htm
OK!!! With this link I’ve solved the problem.
First of all I have to creat a kind of intermediate class, that is where I call the different functions of my .cu file.
Why it works in this intermediate class and not directly in the cpp main? I don’t know, but at less I got my code working :)
Thank you very much!!! :)