LNK1104 when CUDA in separate translation units built on Visual Studio – Nsight Visual Studio Edition

I couldn’t build my VS project because of a linking error. The error happens when I separate CUDA code into separate translation units. I could successfully build it when all the CUDA code was in one .cu file before. I read this document(wrf.ecse.rpi.edu/wiki/ParallelComputingSpring2015/cuda/nvidia/doc/pdf/CUDA_Compiler_Driver_NVCC.pdf) and I added -rdc=true as a flag in Visual studio. Yet, I still got a linking error Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file ‘C:UsersLijindaedalus-computebuildsrc_fwapplicationscomp_solidcomp_cuCMakeFilescomp_solid_cu.dirDebugcomp_solid_cu_intermediate_link.obj’ comp_solid_cu C:UsersLijindaedalus-computebuildsrc_fwapplicationscomp_solidcomp_cuLINK 1

My GPU is NVIDIA GeForce GTX 1050 Ti with Max-Q Design.
My Nsight Version is 2021.2.1
My CUDA Toolkit is 11.4.

Read more here: Source link