LNK2001 Error when compiling CUDA code part of C++ program in Visual Studio 2022

Hi,

I was trying to add a CUDA kernel call to my C++ program. I did this by following this other post. So I made a header file with a function prototype:

textureSeams.cuh

	#pragma once
	#include "cuda_runtime.h"
	#include "device_launch_parameters.h"
	
	#include <stdio.h>
	
	
	namespace TextureSeams {
		void removeSeams(void);
	}

Then I implemented the function in a CUDA file:

textureSeams.cu

	#include "textureSeams.cuh"
	
	__global__ void remove_seams_kernel(void) {
	
	}
	
	namespace TextureSeams {
		void removeSeams(void)
		{
			remove_seams_kernel <<<1,1>>> ();
			printf("Hello, I am in CUDA code!");
		}
	}

Finally, I call the function in my .cpp file as follows:

TextureSeams::removeSeams();

Still, my compiler gives me the following error (in the .obj of my .cpp file):

LNK2001: unresolved external symbol “void __cdecl TextureSeams::removeSeams(void)”(? removeSeams@TextureSeams@@YAXXZ)

I have checked whether $(CUDA_LIB_DIR) was set in my environment variables and have also added it to Properties > Linker > General > Additional Library Directories . Furthermore I added cuda.lib, cudart.lib and curand.lib to Properties > Linker > Input > Additional Dependencies. Am I still missing something or doing something wrong here?

I’m having this issue as well. I fixed it once before, but cannot recall now. It’s something goofy. I include * cuda libs.

edit: I deleted my cu files and added them via the ui new item. it then compiled properly.