Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Community 2017 cl.exe

Tags:

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.

like image 652
cdeterman Avatar asked Mar 14 '17 19:03

cdeterman


People also ask

Where can I find cl exe?

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.

Does Visual Studio community have C?

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 .

Where is MSVC compiler installed?

More precisely, the default path where you'll find the compiler is C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin .

Does Visual Studio community have a compiler?

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.


2 Answers

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:

  • Windows 10, x64
  • Visual Studio Community 2017 already installed, but only for C# development

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:

  1. Start up the Visual Studio Installer
  2. Check the Desktop development with C++ (screenshots here)
  3. 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'.

like image 178
Theo Lenndorff Avatar answered Sep 18 '22 17:09

Theo Lenndorff


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

like image 38
Lou Franco Avatar answered Sep 17 '22 17:09

Lou Franco