Comfy Windows development environment

Mar 2, 2024    #c   #c++   #windows  

This post explains how to set up a comfortable, command-line based development environment for C/C++ applications on Windows.

Acquire Visual Studio

Downloading Visual Studio and installing Windows development packages is the most reliable way to get your hands on cl - Microsoft’s C/C++ compiler.

Microsoft’s gives you a downloader application instead of Visual Studio itself. Run it and install Visual Studio Community 20xx. The default installation should come pre-configured with everything you need including MSVC (the offical name of the compiler. cl is just the executable name), profiling/debugging tools, and ofc the IDE. However you might want to check Windows XX SDK as well.

Add vcvarsall parent directoy to path

Navigate to where you installed Visual Studio and search for a script named vcvarsall. It could for example be at: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build

To add it to path:

(Optional) Subst repo folder

The commandline application subst allows you to take any directory on the filesystem and make it so it appears as a fake partition. I like to do this at the parent directory of my repo or project folder.

subst R: C:\Repo

Invoke build tools from the commandline

Now you should have everything you need to invoke Microsoft’s build utilities from the commandline. My workflow involves:

R: 
cd {repo path}
vcvarsall {architecture, eg. x64}
cl {c/c++ file}
devenv {executable_path}

Resources