I am working on compiling some CUDA kernels on a Windows system. From my understanding, the nvcc
compiler requires the use of cl.exe
to compile on Windows systems. The primary way to get this is with Visual Studio. I have therefore installed the free community edition. After which I expected there to be the bin
directory within the VC
directory as shown in multiple other questions such as this one and this one. And yet, I need to go to several layers deeper to find
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe
This particular project is intended to make a program that can be compiled and used on multiple different Windows systems. Do I really need to expect the cl.exe
file to be this nested or did I miss some sort of installation step here? I was expecting a shorter path:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\bin\
Ultimately I need as simple a way as possible for users to be able to have their environment find the cl.exe file. Generally this involves (at the highest level) setting an environmental variable.
cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. You can start this tool only from a Visual Studio developer command prompt. You cannot start it from a system command prompt or from File Explorer. For more information, see Use the MSVC toolset from the command line.
Visual Studio Code is a lightweight, cross-platform development environment that runs on Windows, Mac, and Linux systems. The Microsoft C/C++ for Visual Studio Code extension supports IntelliSense, debugging, code formatting, auto-completion. Visual Studio for Mac doesn't support Microsoft C++, but does support .
More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .
VS Code is first and foremost an editor, and relies on command-line tools to do much of the development workflow. The C/C++ extension does not include a C++ compiler or debugger. You will need to install these tools or use those already installed on your computer.
I had this problem in a different context (Elixir/Phoenix, Rust), but the root cause was the same: cl.exe
could not be found during compilation.
My setup was:
For some reason the solution with installing the Visual C++ Build Tools (as @cozzamara suggested) did not work. Stops during installation with some obscure error message. Guess it did not liked my existing Visual Studio installation.
This is how I solved it:
Execute following command before compiling:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
From this on the command cl.exe
works. Alternatively (and more conveniently for development) start the application 'Developer Command Prompt for VS 2017' or 'x64 Native Tools Command Prompt VS 2017'.
Look for VCVARSALL.BAT
-- that's usually at a higher level. If you run that it sets up your environment so that you can just call CL without a path.
Documentation here: https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With