Compile Error nvcc fatal : A single input file is required

Hi all, I am using CUDA 7.0 for the first time on my old laptop with GT 540M. When I compile the template program, it throws this error:

nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified

The generated compile command is:

“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe” -gencode=arch=compute_20,code="sm_20,compute_20" --use-local-env --cl-version 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static /FS -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj “C:\CUDA\test\test\kernel.cu”

I am sure that I set the PATH correct. Anyone can help me fix this? Thx!

It was pointed out to you on your cross-posting on SO:

http://stackoverflow.com/questions/39325075/visual-studio-generate-unrecognized-character-of-nvcc-terminal-command

that this /FS switch here:

...-cudart static /FS -g -DWIN32 -...
                  ^^^

is causing the problem. How exactly that came about is not clear, it will depend on how you have set up your VS project.

If I remove that /FS, I get the Error:

Error: C1041: cannot open program database 'c:\vc120.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS

And the MSB3721 error exit code is 2. This is the new compile command:

“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe” -gencode=arch=compute_20,code="sm_20,compute_20" --use-local-env --cl-version 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj “C:\CUDA\test\test\kernel.cu”

So I add a /FS at Project → Properties → CUDA C/C++ → Command Line to avoid this error. Isn’t this the correct solution to C1041?

Very interesting. If I run VS as administrator. Error C1041 will gone and it will throw another different error:

fatal error C1083: Cannot open compiler generated file: 'Debug/kernel.cu.obj': No such file or directory

The compile command is exit with code 1:

“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\bin\nvcc.exe” -gencode=arch=compute_20,code="sm_20,compute_20" --use-local-env --cl-version 2013 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj “C:\CUDA\test\test\kernel.cu”

Actually I encounter this error yesterday and fixed it following this post:http://stackoverflow.com/questions/24106111/compiling-cuda-in-vs2012-fatal-error-c1083-cannot-open-compiler-generated-file, I reset my terminal start directory to C drive. When I normally open VS, this error is gone and throw the C1041. I am totally confused right now.

Turn out the only error right now is:

Error: C1041: cannot open program database 'c:\vc120.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS

Since the nvcc clean command run successfully.

The /FS belongs in the string of switches passed to the host compiler:

-Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd /FS"
                                                 ^^^

Again, you might want to study a sample project.

The error turn out to be the VS is trying to open the program database at C:/vc120.pdb. This is incorrect, it should open pdb file in the Debug folder in the project directory.