3.6. Build Wireshark

The sources contain several documentation files. It’s a good idea to read these files first. After obtaining the sources, tools and libraries, the first place to look at is doc/README.developer. Inside you will find the latest information for Wireshark development for all supported platforms.

[Tip]Build Wireshark before changing anything

It is a very good idea to first test your complete build environment (including running and debugging Wireshark) before making any changes to the source code (unless otherwise noted).

Building Wireshark for the first time depends on your platform.

3.6.1. Building on Unix

Follow the build procedure in Section 2.1, “UN*X” to build Wireshark.

3.6.2. Windows Native

Follow the build procedure in Section 2.2, “Windows: Using Microsoft Visual Studio” to build Wireshark.

After the build process has successfully finished, you should find a Wireshark.exe and some other files in the run\RelWithDebInfo directory.

3.6.3. Build Type

CMake can compile Wireshark for several different build types:

Table 3.1. Build Types

TypeCompiler FlagsDescription

RelWithDebInfo

-O2 -g

Default, build with default optimizations and generate debug symbols. Does not enable extra debugging code or debug level logs

Debug

-O0 -g -DWS_DEBUG -DWS_DEBUG_UTF_8

For debugging, no optimization. Enables extra debugging code

Release

-O3 -DNDEBUG

Optimized for speed, no debug symbols or debug level logs

MinSizeRel

-Os -DNDEBUG

Optimized for size, no debug symbols or debug level logs


The default is RelWithDebInfo, which provides a good compromise of some optimization (-O2) along with including debug symbols (-g) for release builds. For normal development coding you probably want to be using Debug build type or set -DENABLE_DEBUG=On, to enable full logging capabilities and all assertions.

CMake will automatically add the -DNDEBUG option to certain build types but this macro is not used very much in Wireshark code, if at all.

To change the build type, set the CMake variable CMAKE_BUILD_TYPE, e.g.:

$ cmake .. -DCMAKE_BUILD_TYPE=Debug

or on Windows,

> msbuild /m /p:Configuration=Debug Wireshark.sln