https://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWindows.html
2.2. Windows: Step-by-Step Guide
2.2.1. Recommended: Install Chocolatey
Chocolate是Windows环境下的一个自动化的包管理器,它可以帮助你下载Chocolate安裝列表中的所有软件,并且帮组你自动完成安装、升级、卸载等操作,而这所有的操作步骤只需要你输入简单的命令即可完成。
使用如下网站的命令安装,cmd命令使用管理员身份运行:
https://blog.csdn.net/qq_35658349/article/details/87776867
https://www.jianshu.com/p/5325decea0d2
@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
运行如下命令,如果有如下提示表示安装好了:
C:\Windows\system32>choco
Chocolatey v0.12.0
Please run 'choco -?' or 'choco -?' for help menu.
2.2.2. Install Microsoft Visual Studio
安装Microsoft Visual Studio 2019 Community Edition,这是一个微软一些开发包安装的界面程序。
然后再该程序上选择:使用C++的桌面开发
勾选:MSVC v142 - VS 2019 C++ x64/x86生成工具(最新)
也要勾选CMake和SDK10,否则后续会报错。
2.2.3. Install Qt
下载Qt Online Installer for Windows,这是一个Qt Setup引导程序。需要注册账号。
然后在引导程序第六步骤:Select Components
中选择:Qt 5.15.2下的MVSC 2019 64-bit和Qt Debug Information Files。
或者下载源码编译(我没有这么做):
https://download.qt.io/archive/qt/5.15/5.15.2/
2.2.4. Install Python
2.2.5. Install Perl
这里可以选择:https://www.activestate.com/
进入网站,注册后给了一个命令如下。使用管理员身份运行cmd命令,输入:
powershell -Command "& $([scriptblock]::Create((New-Object Net.WebClient).DownloadString('https://platform.activestate.com/dl/cli/AS700/install-latest.ps1'))) -c'state activate --default land-li/Perl-5.34.0-Windows'"
PS: 使用管理员身份运行cmd命令,输入powershell,后输入choco install -y activeperl安装是失败的。所以用了上述方法。
但是该方法还是不行,建议安装strawberryperl:
choco install -y strawberryperl
2.2.6. Install Git
Git不是编译必须的。
使用管理员身份运行cmd命令
powershell
choco install -y git
2.2.7. Install CMake
CMake是可以在安装Visual Studio or Qt时选择安装的。
但是之前没有选,只能手动再安装了,使用choco失败,手动下载安装成功。
2.2.8. Install Asciidoctor, Xsltproc, And DocBook
参考如下网站,JRE32和JRE64都被安装了:
https://community.chocolatey.org/packages/javaruntime
完整命令:
使用管理员身份运行cmd命令
powershell
choco install -y javaruntime
choco install -y asciidoctorj xsltproc docbook-bundle
2.2.9. Install winflexbison
使用管理员身份运行cmd命令
powershell
choco install -y winflexbison3
2.2.10. Install and Prepare Sources
运行cmd命令
cd E:\04.Wireshark\Development
git clone https://gitlab.com/wireshark/wireshark.git
git clone --branch wireshark-3.6.1 https://gitlab.com/wireshark/wireshark.git
2.2.11. Open a Visual Studio Command Prompt
如下网站说明了各个提示命令行的作用,根据提示我们选择x64 Native Tools Command Prompt:
https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-170
- Developer Command Prompt - Sets the environment to use 32-bit, x86-native tools to build 32-bit, x86-native code.
- x86 Native Tools Command Prompt - Sets the environment to use 32-bit, x86-native tools to build 32-bit, x86-native code.
- x64 Native Tools Command Prompt - Sets the environment to use 64-bit, x64-native tools to build 64-bit, x64-native code.
- x86_x64 Cross Tools Command Prompt - Sets the environment to use 32-bit, x86-native tools to build 64-bit, x64-native code.
- x64_x86 Cross Tools Command Prompt - Sets the environment to use 64-bit, x64-native tools to build 32-bit, x86-native code.
如文档建议,编写的批处理文件名称为vcvars64.bat:
Command File | Host and Target architectures | 备注 |
---|---|---|
vcvars32.bat | Use the 32-bit x86-native tools to build 32-bit x86 code. | |
vcvars64.bat | Use the 64-bit x64-native tools to build 64-bit x64 code. | 选择该项 |
vcvars64.bat源码,参考https://blog.csdn.net/Hearbeat/article/details/113575778编写:
rem Let CMake determine the library download directory name under
rem WIRESHARK_BASE_DIR or set it explicitly by using WIRESHARK_LIB_DIR.
rem Set *one* of these.
set WIRESHARK_BASE_DIR=E:\04.Wireshark\Development
rem set WIRESHARK_LIB_DIR=c:\wireshark-win64-libs
rem Set the Qt installation directory
set QT5_BASE_DIR=C:\Qt\5.15.2\msvc2019_64
rem Set the CMake installation directory
set CMAKE_PREFIX_PATHQ=C:\Program Files\CMake\bin
rem Append a custom string to the package version. Optional.
set WIRESHARK_VERSION_EXTRA=-Land-x64
mkdir E:\04.Wireshark\Development\wsbuild64
cd E:\04.Wireshark\Development\wsbuild64
cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark
2.2.13. Build Wireshark
在如下目录编译Wireshark:
E:\04.Wireshark\Development\wsbuild64
msbuild /m /p:Configuration=RelWithDebInfo Wireshark.sln
https://blog.csdn.net/dog_rain/article/details/122182947
msbuild /m /p:Configuration=RelWithDebInfo Wireshark.sln /t:Clean
错误解决方案
错误1:
E:\04.Wireshark\Development\wsbuild64>cmake -G "Visual Studio 16 2019" -A x64 ..\wireshark
-- Selecting Windows SDK version to target Windows 10.0.19042.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:43 (project):
No CMAKE_C_COMPILER could be found.
CMake Error at CMakeLists.txt:43 (project):
No CMAKE_CXX_COMPILER could be found.
-- Configuring incomplete, errors occurred!
解决方案:
进入 设置 -> 应用与功能 -> Microsoft Visual Studio Installer,选择 修改, 然后选择CMake和Win10SDK。
错误2:
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Perl (missing: PERL_EXECUTABLE)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.22/Modules/FindPerl.cmake:84 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:1149 (find_package)
换安装strawberryperl:
使用管理员身份运行cmd命令
powershell
choco install -y strawberryperl
解决掉这两个问题后,终于配置成功了。
参考文档:
https://www.cnblogs.com/zzqcn/p/4823344.html
https://www.wireshark.org/docs/wsdg_html_chunked/ChSetupWindows.html
使用choco安装Notepad++:
使用管理员身份运行cmd命令
powershell
choco install notepadplusplus.install