4.5. Microsoft compiler toolchain (Windows native)

To compile Wireshark on Windows using the Microsoft C/C++ compiler (MSVC), you’ll need:

  1. C compiler (cl.exe)
  2. Assembler (ml.exe for 32-bit targets and ml64.exe for 64-bit targets)
  3. Linker (link.exe)
  4. Resource Compiler (rc.exe)
  5. C runtime headers and libraries (e.g. stdio.h, vcruntime140.lib)
  6. Windows platform headers and libraries (e.g. windows.h, WS2_32.lib)

4.5.1. Official Toolchain Packages And Alternatives

Official releases are or were built with the following Visual C++ versions:

  • Wireshark 4.2.x: Microsoft Visual C++ 2022.
  • Wireshark 4.0.x: Microsoft Visual C++ 2022.
  • Wireshark 3.6.x: Microsoft Visual C++ 2019.
  • Wireshark 3.4.x: Microsoft Visual C++ 2019.
  • Wireshark 3.2.x: Microsoft Visual C++ 2019.
  • Wireshark 3.0.x: Microsoft Visual C++ 2017.
  • Wireshark 2.6.x: Microsoft Visual C++ 2017.
  • Wireshark 2.4.x: Microsoft Visual C++ 2015.
  • Wireshark 2.2.x: Microsoft Visual C++ 2013.
  • Wireshark 2.0.x: Microsoft Visual C++ 2013.
  • Wireshark 1.12.x: Microsoft Visual C++ 2010 SP1.
  • Wireshark 1.10.x: Microsoft Visual C++ 2010 SP1.
  • Wireshark 1.8.x: Microsoft Visual C++ 2010 SP1.
  • Wireshark 1.6.x: Microsoft Visual C++ 2008 SP1.
  • Wireshark 1.4.x: Microsoft Visual C++ 2008 SP1.
  • Wireshark 1.2.x: Microsoft Visual C++ 2008 SP1.
  • Wireshark 1.0.x and earlier: Microsoft Visual C++ 6.0.

Using the release compilers is recommended for Wireshark development work.

“Community” editions of Visual Studio such as “Visual Studio Community 2022” can be used to compile Wireshark but any PortableApps packages you create with them might require the installation of a separate Visual C++ Redistributable package on any machine on which the PortableApps package is to be used. See Section 4.5.5, “Visual C++ Runtime “Redistributable” Files” below for more details.

However, you might already have a different Microsoft C++ compiler installed. It should be possible to use any of the following with the considerations listed. You will need to sign up for a Visual Studio Dev Essentials account if you don’t have a Visual Studio (MSDN) subscription. The older versions can be downloaded from https://visualstudio.microsoft.com/vs/older-downloads/.

4.5.2. Visual C++ 2022 Community Edition

IDE + Debugger?
Yes
SDK required for 64-bit builds?
No

CMake Generator: Visual Studio 17

You can use Chocolatey to install Visual Studio, e.g:

PS:\> choco install visualstudiocommunity2022 visualstudio2022-workload-nativedesktop

If you wish to build Arm64 executables you must install the following components:

Microsoft.VisualStudio.Component.VC.Tools.ARM64
MSVC v143 - VS 2022 C++ ARM64/ARM64EC build tools (Latest)
Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre
MSVC v143 - VS 2022 C++ ARM64/ARM64EC Spectre-mitigated libs (Latest)

4.5.3. cl.exe (C Compiler)

The following table gives an overview of the possible Microsoft toolchain variants and their specific C compiler versions ordered by release date.

Compiler Package

VC++

_MSC_VER

Visual Studio 2022 (17.4.2)

14.34

1934

A description of _MSC_VER and _MSC_FULL_VER, and their relation to Visual Studio and compiler versions, can be found at Microsoft-specific predefined macros.

Information on the VC++ version can be found in the file wsutil/version_info.c.

After correct installation of the toolchain, typing at the Visual Studio Command line prompt (cmd.exe):

> cl

should result in something like:

Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28106.4 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

However, the version string may vary.

Documentation on recent versions of the compiler can be found at Microsoft Docs

4.5.4. link.exe (Linker)

After correct installation, typing at the Visual Studio Command line prompt (cmd.exe):

> link

should result in something like:

Microsoft (R) Incremental Linker Version 14.23.28106.4
Copyright (C) Microsoft Corporation.  All rights reserved.

 usage: LINK [options] [files] [@commandfile]
 ...

However, the version string may vary.

Documentation on recent versions of the linker can be found at Microsoft Docs

4.5.5. Visual C++ Runtime “Redistributable” Files

Please note: The following is not legal advice. Ask your preferred lawyer instead. It’s the authors view and this view might be wrong.

Wireshark and its libraries depend on POSIX functions such as fopen() and malloc(). On Windows, these functions are provided by the Microsoft Visual C++ C Runtime (CRT). There are many different versions of the CRT and Visual C++ 2015 and later use the Universal CRT (UCRT).

The Universal CRT comes standard with Windows 10 and is installed as part of Windows Update on earlier versions of Windows. The Wireshark .exe installers include redistributables (vc_redist.x64.exe or vc_redist.x86.exe) which ensure that the Universal CRT is installed and up to date.

[Note]Make sure you’re allowed to distribute this file

The files to redistribute must be mentioned in the redist.txt file of the compiler package. Otherwise it can’t be legally redistributed by third parties like us.

The following Microsoft Docs link is recommended for the interested reader:

Redistributing Visual C++ Files

In all cases where vc_redist.x64.exe or vc_redist.x86.exe is downloaded it should be downloaded to the directory into which the support libraries for Wireshark have been downloaded and installed. This directory is specified by the WIRESHARK_BASE_DIR or WIRESHARK_LIB_DIR environment variables. It need not, and should not, be run after being downloaded.

4.5.6. Windows Platform SDK

The Windows Platform SDK (PSDK) or Windows SDK is a free (as in beer) download and contains platform specific headers and libraries (e.g. windows.h, WSock32.lib, etc.). As new Windows features evolve in time, updated SDKs become available that include new and updated APIs.

When you purchase a commercial Visual Studio or use the Community Edition, it will include an SDK.