Call CUDA functions from CPP File

Hi. I created a CUDA project in visual studio, with the typical CUDA Sample of adding 2 arrays (

I want to try to call this 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 )
return 0;


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 :)

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!!! :)