Wireshark Developer’s Guide Version 3.7.0 --- 2. Quick Setup

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 <command> -?' 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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,753评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,668评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,090评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,010评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,054评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,806评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,484评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,380评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,873评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,021评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,158评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,838评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,499评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,044评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,159评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,449评论 3 374
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,136评论 2 356

推荐阅读更多精彩内容