Error compiling CUDA from Command Prompt - cuda

I'm trying to compile a cuda test program on Windows 7 via Command Prompt,
I'm this command:
nvcc test.cu
But all I get is this error:
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
What may be causing this error?

You will need to add the folder containing the "cl.exe" file to your path environment variable. For example:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin
Edit: Ok, go to My Computer -> Properties -> Advanced System Settings -> Environment Variables. Here look for "PATH" in the list, and add the path above (or whatever is the location of your cl.exe).

For new Visual Studio cl.exe is present in path => C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64
x64 is for 64bit
x86 is for 32bit

Solve this problem by adding this options to nvcc
nvcc x.cu ... -ccbin "D:\Program Files\Microsoft Visual Studio 11.0\VC\bin"
for example my compiler is VS2012. and cl.exe is in this dir

cl.exe is Microsoft's C/C++ compiler. So the problem is that you don't have that installed where the command line can find it.

nvcc is only a front end for the CUDA specific part of the program. It must invoke a full compiler to finish the job. In this case it cannot find the Visual Studio compiler 'cl.exe'
Check paths, nvcc documentation etc.

I see that this is an old question but I recently got this error on my Visual Studio 2012 when I tried to build my CUDA project. Apparently I had changed my CUDA project to the Nov 2012 pack, changing it back to the v110 that it usually is by default fixed this error.
In Visual Studio, left click on the CUDA project, ->properties->Configuration Properties-> General -> Platform toolset, and choose: Visual Studio 2012 (v110).
I could probably get it to work with the Nov 2012 pack, but the CUDA code does not use any of the additional functions of that pack, so it is not necessary. (That pack contains the variadic templates for C++11.)

Solve this problem by adding the path to environment variables, which can vary slightly depending in the version of visual studio installed in your system, and are you using 32bit or 64bit system
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64

Related

Unable to build SSIS package from command line: Missing switch argument. Configuration name required for /build switch

I am trying to script out the building of an SSIS solution in VS 2013.
I keep getting the error: Missing switch argument. Configuration name required for /build switch.
My Command is this from PowerShell:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> .\devenv.exe C:\Dev\SSIS\RCLShippedFileProcess\RCLShippedFileProcess.sln /build /project RCLShippedFile /projectconfig "Debug"
When I build within Visual Studio, I can see that my ProjectName and the Config are what I am passing in. This certainly has me stumped!
Documentation about this is here.
I ended up resolving the issue, I needed to call the devenv.com application, which is ultimately what devenv.exe calls. If you call devenv.com directly it worked.
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE> .\devenv.exe C:\Dev\SSIS\RCLShippedFileProcess\RCLShippedFileProcess.sln /build "Debug"

Compile Error While Building MySQL connector from sources

I'm building MySQL C connector 6.1.0 for my Visual Studio 10. It does compile fine for 32-bit after the following steps:
Launch Visual Studio Command Prompt (as Administrator!).
cmake . -G "Visual Studio 10"
devenv libmysql.sln /build Release
for the debug:
cmake . -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug
devenv libmysql.sln /Rebuild Debug
But if I try to build it for 64-bit architecture using "cmake . -G "Visual Studio 10 Win64" compiler fires an error:
11>my_atomic.c(30): error C2118: negative subscript
for the following line of code:
compile_time_assert(sizeof(intptr) == sizeof(void *));
My intuition suggests, that the compiler didn't doesn't compile it for the 64-bit. Trying to pass such parameters to cmake doesn't help:
cmake . -G "Visual Studio 10 Win64" -DCMAKE_C_FLAGS="-m64" -DCMAKE_CXX_FLAGS="-m64"
One more remark: the file "my_atomic.c" belongs to the project "mysys" and it is being compiled as C code (/TC option under Configuration Properties->C/C++->Advanced.
Any ideas?
My own fault: for 64-bit have to run Visual Studio x64 Win64 Command Prompt !

how does msbuild decide which tools to use?

I'm trying to setup a new TeamCity agent.
My new agent is calling:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe
While the existing agents are calling:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\AMD64\CL.exe
The existing agents are doing the right thing as far as I'm concerned, because both are 64bit host and building 64bit binaries. Both are calling msbuild with the same arguments (specifics removed to protect the innocent):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe (xxxx.sln /clp:PerformanceSummary /p:Configuration=Release /p:Platform=x64)
I've found this blog: http://blogs.msdn.com/b/aaronhallberg/archive/2007/07/16/msbuild-property-evaluation.aspx, which explains how msbuild evaluate properties. But I don't know what properties are used to decide about the tools.
You might wonder why I care about the tool choice. The CL calls succeed in either case (you can run the 32 bit compile under 64bit windows). But on the new agent, I'm getting an error on a pre-compiled header "precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa)" - and the pre-compiled header is being consumed by the same AMD64\CL.exe.
So if anyone knows which props msbuild actually uses, it would help me figure this out.
As a side note, I see the cross compiler (x86_amd64\CL.exe) in Visual Studio projects property pages under VC++ Directories, Executable Directories, on my workstation. Which is Win 7, 64bit. It says it is inherited, and I haven't customized the msbuild props (in C:\Users\bdelavega\AppData\Local\Microsoft\MSBuild\v4.0). Why would that be the default?
This post explains that msbuild defaults to using the cross compiler when called from VS 2010 and that there is a command line switch to override it.
http://social.msdn.microsoft.com/Forums/en-US/vcprerelease/thread/d6b352ea-12b6-4867-b86d-a052fbab1da4
It's not the complete answer, but it gives me enough to overcome my issue.

LNK1104: cannot open file 'glut32.lib'

I am using "CUDA bu Example" book to get started with CUDA.
But when I included all header files given by book then got ERROR as
Error 1 error LNK1104: cannot open file 'glut32.lib' D:\book\book\LINK book
I am using Visual Studio 10
Please help me out of this
I found the same error while setting it up in Visual Studio 2010
However, I also found a fix and wanted to share it.
Just copy and paste the glut32.lib file to MicrosoftSDKs folder, as this is the default location of VC++ linker location. To be exact
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
You probably have to build the "shrUtils_vs2010.sln" solution if you haven't done it.
The file is in "\path_to_SDK\NVIDIA GPU Computing SDK 4.2\shared" folder.
Copy the glut32.lib file from the lib folder in "cuda by example" to the folder below:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\lib\Win32
I have tested this solution and it worked for me in visual studio 2015
1: Copy glut32.dll to your project directory (where your source.cpp is)
2: Copy glut.h to C:\Program Files\Microsoft Visual Studio 14.0\Vc\Include\gl (gl folder should be created manually)
3: Copy glut32.lib to C:\Program Files\Microsoft Visual Studio 14.0\Vc\lib done.

cutil.h CUT_SAFE_CALL in CUDA 4.0

I am using CUDA 4.0 . I am trying to use the following functions.
CUT_DEVICE_INIT();
CUT_SAFE_CALL(cutCreateTimer(&hTimer));
I included cutil.h to use the above functions. But the compiler reports the following..
fatal error C1083: Cannot open include file: 'cutil.h': No such file or directory
I searched in the CUDA directory but there is no file 'cutil.h'.
How can I find the time needed for a CUDA function using the above method? (not using the C++ timer)
You probably didn't tell your compiler where to find the file. I can't tell you exactly because you didn't provide details on what system you are using but for example, on Windows XP and assuming a default installation of version 4.0 of the SDK the cutil.h header file is in:
C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
For Windows 7 I think it is:
C:\Program Data\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C\common\inc
but not sure.