1 Building tcpdump on Windows with Visual Studio
2 ==============================================
4 Unlike the UN*Xes on which libpcap can capture network traffic, Windows
5 has no network traffic capture mechanism that libpcap can use.
6 Therefore, libpcap requires a driver, and a library to access the
7 driver, provided by the Npcap or WinPcap projects.
9 Those projects include versions of libpcap built to use that driver and
10 library; these instructions are for people who want to build libpcap
11 source releases, or libpcap from the Git repository, as a replacement
12 for the version provided with Npcap or WinPcap.
17 In order to build tcpdump, you will need to download Npcap and its
18 software development kit (SDK) or WinPcap and its software development
21 Npcap is currently being developed and maintained, and offers many
22 additional capabilities that WinPcap does not.
24 WinPcap is no longer being developed or maintained; it should be used
25 only if there is some other requirement to use it rather than Npcap,
26 such as a requirement to support versions of Windows earlier than
27 Windows Vista, which is the earliest version supported by Npcap.
29 Npcap and its SDK can be downloaded from its home page:
31 https://npcap.org
33 The SDK is a ZIP archive; create a folder on your C: drive, e.g.
34 C:\npcap-sdk, and put the contents of the ZIP archive into that folder.
36 The WinPcap installer can be downloaded from
38 https://www.winpcap.org/install/default.htm
40 and the WinPcap Developer's Kit can be downloaded from
42 https://www.winpcap.org/devel.htm
47 The Developer's Kit is a ZIP archive; it contains a folder named
48 WpdPack, which you should place on your C: drive, e.g. C:\WpdPack.
50 Building tcpdumpp on Windows requires Visual Studio 2015 or later. The
51 Community Edition of Visual Studio can be downloaded at no cost from
53 https://visualstudio.microsoft.com
55 Additional tools are also required. Chocolatey is a package manager for
56 Windows with which those tools, and other tools, can be installed; it
57 can be downloaded from
59 https://chocolatey.org
61 It is a command-line tool; a GUI tool, Chocolatey GUI, is provided as a
62 Chocolatey package, which can be installed from the command line:
64 choco install chocolateygui
66 For convenience, the "choco install" command can be run with the "-y"
67 flag, forcing it to automatically answer all questions asked of the user
70 choco install -y chocolateygui
72 The required tools are:
76 libpcap does not provide supported project files for Visual Studio
77 (there are currently unsupported project files provided, but we do not
78 guarantee that they will work or that we will continue to provide them).
79 It does provide files for CMake, which is a cross-platform tool that
80 runs on UN*Xes and on Windows and that can generate project files for
81 UN*X Make, the Ninja build system, and Visual Studio, among other build
84 Visual Studio 2015 does not provide CMake; an installer can be
87 https://cmake.org/download/
89 When you run the installer, you should choose to add CMake to the system
90 PATH for all users and to create the desktop icon.
92 CMake can also be installed as the Chocolatey package "cmake":
94 choco install -y cmake
96 Visual Studio 2017 and later provide CMake, so you will not need to
97 install CMake if you have installed Visual Studio 2017 or later. They
98 include built-in support for CMake-based projects:
100 https://devblogs.microsoft.com/cppblog/cmake-support-in-visual-studio/
102 For Visual Studio 2017, make sure "Visual C++ tools for CMake" is
103 installed; for Visual Studio 2019, make sure "C++ CMake tools for
104 Windows" is intalled.
109 An optional tool, required only if you will be building from a Git
110 repository rather than from a release source tarball, is Git. Git is
111 provided as an optional installation component, "Git for Windows", with
112 Visual Studio 2017 and later.
114 Building from the Visual Studio GUI
115 -----------------------------------
117 ### Visual Studio 2017 ###
119 Open the folder containing the libpcap source with Open > Folder.
120 Visual Studio will run CMake; however, you will need to indicate where
121 the Npcap or WinPcap SDK is installed.
123 To do this, go to Project > "Change CMake Settings" > tcpdump and:
125 Choose which configuration type to build, if you don't want the default
128 In the CMakeSettings.json tab, change cmakeCommandArgs to include
130 -DPacket_ROOT={path-to-sdk}
132 where {path-to-sdk} is the path of the directory containing the Npcap or
133 WinPcap SDK. Note that backslashes in the path must be specified as two
136 Save the configuration changes with File > "Save CMakeSettings.json" or
139 Visual Studio will then re-run CMake. If that completes without errors,
140 you can build with CMake > "Build All".
142 ### Visual Studio 2019 ###
144 Open the folder containing the libpcap source with Open > Folder.
145 Visual Studio will run CMake; however, you will need to indicate where
146 the Npcap or WinPcap SDK is installed.
148 To do this, go to Project > "CMake Settings for tcpdump" and:
150 Choose which configuration type to build, if you don't want the default
153 Scroll down to "Cmake variables and cache", scroll through the list
154 looking for the entry for Packet_ROOT, and either type in the path of
155 the directory containing the Npcap or WinPcap SDK or use the "Browse..."
156 button to browse for that directory.
158 Save the configuration changes with File > "Save CMakeSettings.json" or
161 Visual Studio will then re-run CMake. If that completes without errors,
162 you can build with Build > "Build All".
164 Building from the command line
165 ------------------------------
167 Start the appropriate Native Tools command line prompt.
169 Change to the directory into which you want to build tcpdump, possibly
170 after creating it first. One choice is to create it as a subdirectory
171 of the tcpdump source directory.
175 cmake "-DPacket_ROOT={path-to-sdk}" {path-to-tcpdump-source}
177 where {path-to-sdk} is the path of the directory containing the Npcap or
178 WinPcap SDK and {path-to-tcpdump-source} is the pathname of the
179 top-level source directory for tcpdump.
183 msbuild/m tcpdump.sln