1. Introduction
Refer to the Wireshark Development Guide, Chapter 2nd, "Quick Setup" for the relevant contents of this article
To modify the Wireshark code, in addition to the following description of the LUA plug-in mode, you need to compile the Wirehshark source code (c external Parsing plug-in does not need to compile the entire wireshark, all need to download Wireshark source code and the required library), Therefore, it is necessary to learn how to build wireshark development environment.
Compiling Wireshark on Linux and Apple OS x systems is simple, here withheld, only describes the methods and procedures for compiling Wireshark 64-bit versions of Windows.
The following steps are described in order, which is based on the Wireshark 1.12.x and 1.99.x versions, and the other older versions are similar.
1. Windows1.1 Download Source code
SOURCE Compression Package: https://www.wireshark.org/download/src/all-versions/
Git (should be the main line): Git clone Https://code.wireshark.org/review/wireshark
1.2 Preparing Visual C + +
To compile Wireshark, you should have Visual Studio installed on your development PC and include Visual C + +, install Visual Studio 2010 at least to reduce unnecessary hassles.
1.3 Installing QT (Optional)
To http://www.qt.io/download-open-source/#section-2 Download the QT version that corresponds to your version of Visual Studio and processor architecture.
Note that the current QT official installation package only provides 64bit support for Visual Studio 2013, and to compile Wireshark with Visual Studio 2010, you need to download the QT opensource source code and compile it yourself into a 642 library.
1.4 Preparing PowerShell (Optional)
It is necessary to install PowerShell on the old system before Win7 to compile Wireshark new version.
1.5 Installing Cygwin and related packages
To http://www.cygwin.com/download the Cygwin installer, perform an online installation, and you will see later that if you use the old Cygwin version, you may cause errors. When you are prompted to install, select the following package (* number is optional):
- Archive/unzip
- *archive/zip (needed if you intend to build the U3 package)
- Devel/bison
- Devel/flex
- *devel/subversion (Optional-see discussion about using subversion below)
- Interpreters/perl
- Utils/patch
- Web/wget
Assume that it is installed to C:\Cygwin64.
1.6 Installing Python
Download install Python version 2.7 to https://www.python.org/, assuming installation to C:\Python27
1.7 Preparing the command line for compilation
A batch file, such as SetEnv.bat, is built into the Wireshark source master directory, as follows
@ECHO offSET PATH=%PATH%:.SETCygwin_bin=c:\cygwin64\binSETQt5_base_dir=d:\dev\qt-everywhere-opensource-src-5.3.2\QtbaseSETQt5_bin=d:\dev\qt-everywhere-opensource-src-5.3.2\qtbase\LiSET PATH=%PATH%;%cygwin_bin%;%qt5_bin%SETwireshark_lib_dir=d:\dev\wireshark-win64-libs-1.12SETvisualstudioversion=10.0SETplatform=X64SETWireshark_version_extra=-zzq-x64ECHOSet Visual Studio Environment ...Pager"C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\vcvarsall.bat"Amd64titleCommand Prompt(msvc++ 64bit)GOTO : EOF
Explain:
- Cygwin_bin:cygwin executable file directory
- QT_5XXX:QT Related Categories
- Visualstudioversion: The version number of the Visual Studio that is used for compilation
- PLATFORM: Target platform, Wireshark compiled to 32-bit or 64-bit
- Wireshark_version_extra: Additional version information, this string will appear in the compiled WIRESHARK "about WIRESHARK" dialog box in the version information
- Call Line: Indicates setting the Visual C + + 2010 64-bit compilation mode environment variable
If you do not want to compile the QT version, the script is changed to the following:
@ECHO offREMBatch script for compiling Wireshark on Windows.REMI have disabled the Qt version build because it ' s meaningfulREMIn 1.99.x only I think.SET PATH=%PATH%:.SETCygwin_bin=c:\cygwin64\binREMSET qt5_base_dir=d:\dev\qt-everywhere-opensource-src-5.3.2\qtbaseREMSET Qt5_bin=d:\dev\qt-everywhere-opensource-src-5.3.2\qtbase\binREMSET path=%path%;%cygwin_bin%;%qt5_bin%SET PATH=%PATH%;%cygwin_bin%SETwireshark_lib_dir=d:\dev\wireshark-win64-libs-1.12SETvisualstudioversion=10.0SETplatform=X64SETWireshark_version_extra=-zzq-x64ECHOSetup Visual Studio Environment ...Pager"C:\Program Files (x86) \microsoft Visual Studio 10.0\vc\vcvarsall.bat"Amd64titleCommand Prompt(msvc++ 64bit)GOTO : EOF
1.8 Modify/config.nmake File
Open the Wireshark source directory under the Config.nmake file, make the following changes
- Locate the wireshark_lib_dir= and set it to the directory where the Wireshark compilation depends on the third-party library file, as explained below
- Find local_cflags= and add the desired compiler flag
The settings in this file are numerous and can be modified to suit your needs.
1.9 Check if the compilation tool chain is ready
Open the Wireshark source directory in the SetEnv.bat, (open after you do not turn off, and later to use), run
Nmake-f Makefile.nmake Verify_tools
As shown in the following:
If there is no error, all the software and tools needed to prove the compilation are installed.
1.10 Installing third-party dependent libraries
Compiling Wireshark relies on a number of third-party libraries, as shown in
These libraries can be downloaded automatically using the Wireshark compilation script, or they can be downloaded manually. These libraries are:
http://anonsvn.wireshark.org/wireshark-$WIRESHARK _target_platform-libs/tags/$DOWNLOAD _tag/packages/
Where $wireshark_target_platform is replaced with the target platform you want to compile, such as Win32 or Win64, $DOWNLOAD _tag to replace with a date string. For example, I want to compile version 1.12.0, this address is:
Http://anonsvn.wireshark.org/wireshark-win64-libs/tags/2014-06-19/packages/.
If the network quality is good, can run directly
Nmake-f makefile.nmake Setup
From the download installation dependent library.
1.11 Start compiling
Run first
Nmake-f Makefile.nmake Distclean
To clean up the old files and then run
namke-f Makefile.nmake All
Start compiling. On the Intel i5-4590 CPU and 8GB memory machine, the compilation process takes about 7 minutes.
2. Mac OSX
Take 1.99.8 as an example.
- Download the source code and unzip
- Go to the home directory, run./macosx-setup.sh, and follow the prompts to install all required dependencies
If you do not need QT support, please comment out the qt_version=x.y.z line in macosx-setup.sh, and do not add QT-related things in step 4th
- Set 3 environment variables
- exportpkg_config_path=/usr/local/lib/pkgconfig:/users/zzq/qt5.5.0/5.5/clang_64/lib/pkgconfig:/usr/x11/lib/ Pkgconfig
- Exportcmake_prefix_path=:/users/zzq/qt5.5.0/5.5/clang_64/lib/cmake
- Exportpath=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/x11/bin:/users/zzq/qt5.5.0/5.5/clang_64/bin
- mkdir build; CD Build
- CMake.
- Make–j 6 App_bundle
If Wireshark 1.12.6, for Make–j 6 all
- The compiled files under Build/run can also be made install installation
When compiling with CMake, the default compilation options are determined by the CMakeList.txt in the home directory
if (not Cmake_build_type) set (Cmake_build_type relwithdebinfo CACHE STRING "Choose the Type of build, Options Are:none Debug Release relwithdebinfo minsizerel. " Force ) endif ()
Set to Relwithdebinfo, if you want to develop debugging, preferably set to debug. Can be set here, or can be set on the CMake command line:
Cmake–dcmake_build_type=debug.
In addition, in order for Mac OSX to compile the GTK + version of the Wireshark can run, you need to start X11 (installed by quartz, default in Launchpad "other"), and then enter export display=:0.0 in the shell, and then run. /wireshark can do it.
3. Reference
Wireshark Development Guide, Chapter 2nd, "Quick Setup"
Construction of "Wireshark" development environment