How to separately compile a kernel in Visual Studio

This is not a question, but rather something I learned and I want other developers to find the information if they look for it.

I created a VS project (VS 17) by copying a project file from one of the CUDA Samples, then removed the source files and added my own files. One file,, contained kernel code, which I call in another file,

Things built and ran just fine, until one day I somehow changed the properties on, from --compile to --cubin. I thought that since contained no host code, only the global void Kernel (), then I didn’t need to create a host object file.

Well that was wrong. When I built the project, the host linker said that void Kernel () was missing. It seems that there’s no in the link step.

So the lesson is: If your file contains a kernel that will be referenced from host code elsewhere in the program, you must specify --compile in the Properties (CUDA/C++ : Common : Compilation Type).