MSVC Toolchain and Windows Native Build

The Windows native build stack end to end: cl.exe and link.exe, the developer environment, MSBuild versus CMake, the CRT variants and the mismatched-runtime crash, DLL exports, PDBs, and pinning a toolset in CI.

Overview

A full second toolchain

Windows native C++ is a full second toolchain, not a porting detail. 'Strong knowledge of MSVC libraries' means debugging a build with no Unix tooling: cl.exe compiles, link.exe links, the standard library is Microsoft's, symbols live in a separate file, and nothing is exported from a DLL unless you say so.

The whole chain fits in one picture. A batch file sets up the environment, a build system drives the compiler, and the linker joins everything into an EXE or a DLL. Two decisions hang off the linker: which C runtime the binary uses, and where its debug symbols go. The sections after the figure take each piece in turn.

Key concepts

  • Developer command prompt and vcvarsall
  • The three-part CRT
  • Mismatched runtime
  • dllexport, dllimport and .def
  • Import library versus static library
  • PDB and debug information format
  • /permissive- and conformance
  • Toolset version, Visual Studio version, Windows SDK

Interview questions

  • A DLL crashes inside free() when the host EXE passes it an object to delete. Walk through the cause and the fixes.
  • How do you produce, ship and use PDBs so that a production crash is actually debuggable?
  • You are setting up Windows CI for a C++ project. How do you pin and locate the toolchain, and what are the failure modes?
  • Explain __declspec(dllexport)/dllimport versus a .def file, and how you would structure exports for a library with external consumers.
  • What does /permissive- change, why would you adopt it, and what breaks first?
  • An application fails to start on a customer machine with a missing-DLL or 0xc000007b error. How do you diagnose it?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio