Using cl.exe for 32 and 64 bits


I was trying to build my project for both 32 and 64 bits. After a lot of work (I’m not familiar with developing on Windows) I figured out I should use the VS compiler (cl.exe), and to be able to compile to both 32 and 64 bits I should run the vcvars32.bat and vcvars64.bat script (inspired by this).

However, even though visualstudio2017buildtools is installed by default, it seems this bat files are not included. I managed to get them by installing more packages with choco install -y visualstudio2017community visualstudio2017-workload-nativecrossplat. This worked in the end (see commit), but it takes about 10 minutes for Travis to run this (in comparison, the Linux and OSX builds take about 1 minute see here)

My question is: Is there a better and faster way to do this? This solution seems pretty hacky.


I’d also like an answer to this. I have a stupid simple build setup for my project right now - I’m basically just running cl.exe on windows and it produces an executable file.

I’m unable find any way to get the path to cl.exe or the vcvars64.bat script.

Creating a project for msbuild just to get this going seems overkill when I just need access to cl.exe.

I was able to build using cl.exe after installing vctools like so:

choco install visualstudio2017-workload-vctools -y

It only took a couple of seconds.

My log:

Interestingly, it seemed to find MSVC 2014?

"Using " C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\

using “/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/vcvarsall.bat”

Huh, when I tried the install was minutes… will try again.

The original poster referred to another package than I did. Maybe that’s why it only took seconds for me?

Yeah, probably. Tested it and it fast and nice. Thanks!