Unresolved external symbols in beginners CUDA program

I guess you are missing to link to the correct library. Make sure you have the CUDA library added under "Configuration Properties->Linker->Input". Refer this.


Two things are needed:

  1. Add CUDA path:
    Go: "Configuration Properties->Linker->General->Additional Libary Directories" and add $(CudaToolkitLibDir) to the list.

  2. Add CUDA runtime library:
    Go: "Solution Properties->Linker->Input->Additional Dependencies" and add cudart.lib to the list.


In visual studio 2019:

Double check the availability of CUDA_PATH environment variable.

Configuration Properties -> VC++ Directories -> Include Directories -> Add $(CUDA_PATH)\include

Configuration Properties -> VC++ Directories -> Library Directories -> Add $(CUDA_PATH)\lib\x64

Configuration Properties -> Linker -> Input -> Additional Dependencies -> Add .lib files under $(CUDA_PATH)\lib\x64 and ignore existing .lib files.