#mac# Mac上编译Wireshark

因需要再Wireshark上做插件协议二次开发,因此需在Mac上进行编译Wireshark

Wireshark是用Qt展示界面的,在编译安装Wireshark之前需要安装Qt,而安装Qt所需空间不小,估算至少占用20G的空间,所以在执行下列步骤之前先确保你的Mac至少有20G的剩余空间。

源码下载

我们可以从官方网站上下载Wireshark源码进行编译。或者从github上进行下载,建议从官网上下载,因为大部分人使用的是官网上版本,Github上的版本可能会与官网上的版本不匹配现象。注意下当前具体版本号。

Wireshark · Go Deepy

#mac# Mac上编译Wireshark_第1张图片

 https://github.com/wireshark/wireshark

安装XCODE

。可能会有一下问题-使用app安装的xcode,此时运行xcodebuild会提示没有安装。是因为安装路径不是默认路径。需要修改为默认路径即可:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer


运行macosx-setup.sh

准备好科学上网,避免timeout

下载安装系统需要的软件。可能出现有些软件无法下载,比如lzip下载失败,那么可以注释掉这个安装,使用brew install lzip。或者修改它的下载网址即可,将环境准备好。一切成功后会提示后续的安装步骤,若步骤1没设置默认路径的话,可能会提示以下信息

Please install Xcode first (should be available on DVD or from the Mac App Store). 

#mac# Mac上编译Wireshark_第2张图片
 持续等待,知道运行完成,注意是否以一些提示信息。以及环境配置错误。
#mac# Mac上编译Wireshark_第3张图片

可能出现有些软件无法下载,比如lzip下载失败,那么可以注释掉这个安装,使用brew install lzip。或者修改它的下载网址即可...

brew install lz4
brew install libssh
brew install spandsp
brew install speexdsp
brew install minizip

 将环境准备完成#mac# Mac上编译Wireshark_第4张图片

编译CMAKE 

mkdir build
cd build
cmake -G Ninja ..
ninja wireshark_app_bundle
ninja install/strip

环境检查中的../configure最难通过,里面会有关于Qt的错误(我遇到的)。如:Qt was not requested and GTK+ is not available, so Wireshark can't be compiled这样的错误。可能你在上一步已经安装了Qt或者GTK+但是还是提示这个,那么就是环境没有配置好。

By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has

   asked CMake to find a package configuration file provided by "Qt5Core", but

   CMake did not find one.

   Could not find a package configuration file provided by "Qt5Core" with any

   of the following names:

     Qt5CoreConfig.cmake

     qt5core-config.cmake

 将原路径/usr/local/opt/qt5替换为/opt/homebrew/opt/qt5

编译通过程后,安装我们很容易看到Wireshark.app被安装到了/usr/local/bin/

#mac# Mac上编译Wireshark_第5张图片

将app拷贝到/Applications路径即可。

cp -rf /usr/local/bin/Wireshark.app /Applications

#mac# Mac上编译Wireshark_第6张图片

#mac# Mac上编译Wireshark_第7张图片

你可能感兴趣的:(macos,wireshark,测试工具)