Entry point error with wrapper function method

Hi everyone! I am currently trying to embed some cuda kernel in a C++ program using the wrapper function method.
Here is my testing code:
kernel_wrapper.cu

#include <stdio.h>

extern "C" void kernel_wrapper(int *a, int *b);

__global__ void kernel(int *a, int *b)
{
	int tx = threadIdx.x;

switch( tx ){
  case 0:
    *a = *a + 10;
    break;
  case 1:
    *b = *b + 3;
    break;
  default:
    break;
  }
}

void kernel_wrapper(int *a, int *b)

{
  int *d_1, *d_2;
  dim3 threads( 2, 1 );
  dim3 blocks( 1, 1 );

  cudaMalloc( (void **)&d_1, sizeof(int) );
  cudaMalloc( (void **)&d_2, sizeof(int) );

  cudaMemcpy( d_1, a, sizeof(int), cudaMemcpyHostToDevice );
  cudaMemcpy( d_2, b, sizeof(int), cudaMemcpyHostToDevice );

  kernel<<< blocks, threads >>>( d_1, d_2 );
  cudaMemcpy( a, d_1, sizeof(int), cudaMemcpyDeviceToHost );
  cudaMemcpy( b, d_2, sizeof(int), cudaMemcpyDeviceToHost );
  
  cudaFree(d_1);
  cudaFree(d_2);
}

main.cpp

#include <stdio.h>
#include <stdlib.h>

extern "C" void kernel_wrapper(int *a, int *b);

int main(int argc, char *argv[])
{

int a = 2;
int b = 3;

printf("Input: a = %d, b = %d\n",a,b);

kernel_wrapper(&a, &b);

printf("Ran: a = %d, b = %d\n",a,b);

return 0;

}

when i try to compile the .cu file, i get the following error
LINK : fatal error LNK1561: entry point must be defined

I did some resarch on the on internet and then understood that it has connection with the non existence of a main function. But if i do write a main function it would be impossible to call the wrapper function since its parameters a ant b won’t be recognized.
Any ideas ?

Check your build settings. You seem to be linking the object file produced by compiling kernel_wrapper.cu by itself. That causes the linker to complain about a missing main() which is required to produce an executable application. You want to compile both kernel_wrapper.cu and main.cpp and then link the resulting object files. Either of the following two approaches works to accomplish that.

C:\Users\njuffa\My Programs>nvcc -c kernel_wrapper.cu
kernel_wrapper.cu

C:\Users\njuffa\My Programs>nvcc main.cpp kernel_wrapper.obj
main.cpp
kernel_wrapper.obj
   Creating library a.lib and object a.exp

C:\Users\njuffa\My Programs>main
result=0
result=0
result=0
result=0
gd=1
C:\Users\njuffa\My Programs>nvcc main.cpp kernel_wrapper.cu
main.cpp
kernel_wrapper.cu
   Creating library a.lib and object a.exp

C:\Users\njuffa\My Programs>main
result=0
result=0
result=0
result=0
gd=1

Thanks njuffa, that really helps.

Just being curious, is it possible to use this method to embedd some CUDA kernels in a GUI project with Visual Studio.