Ubuntu 自己编译安装wireshark遇到的问题和解决方法

时间:2022-09-11 21:21:08

如果仅仅是使用wireshark,我们可以在软件中心直接安装,不必这么麻烦。我在这里主要是因为要编写插件所以要下载源代码自己编译安装。

所有安装包网址:https://www.wireshark.org/download/win64/all-versions/


安装方法:

1.从wireshark站点https://www.wireshark.org/download/src/all-versions/下载源代码并解压(例如 wireshark-1.6.5.tar.bz2).

2.进入源代码的目录,运行configure命令进行编译: ./configure

3.运行make命令进行编译: make

4.如果需要安装,则执行下述命令:sudo  make install


以下是执行./configure命令时遇到的问题。

1.configure: error: I couldn't find yacc (or bison or ...); make sure it's installed and in your path 

    sudo apt-get install flex bison  

yacc(Yet Another Compiler Compiler),是Unix/Linux上一个用来生成编译器的编译器(编译器代码生成器)。


2.configure: error: Qt is not available

sudo apt-get install qt5-default


3.Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
configure: error: GTK+ 3 is not available

sudo apt-get install libgtk-3-dev


4. configure: error: Header file pcap.h not found; if you installed libpcap from source, did you also do "make install-incl", and if you installed a binary package of libpcap, is there also a developer's package of libpcap,  
    and did you also install that package?  
问题原因是ubuntu下缺少pcap.h等文件。
解决方法:
编译安装libpcap.
在www.tcpdump.org页面中可下载源码:libpcap-1.0.0.tar.gz
cd到文件目录:
    $tar -xvf libpcap-1.0.0.tar.gz  
    $cd libpcap-1.0.0.tar.gz  
    $./configure  
    $make  
    $sudo make install  
5.'aclocal-1.14' is missing on your system. 
You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
用软件中心安装Synaptic Package Manager,然后在安装autotools-dev  autoconf2.13,这样就可以make通过了。
在修改了源代码主目录下的configure文件,然后再执行./configure命令。这样就会再插件源代码目录生成Makefile文件。最后进入插件源代码目录之赐你个命令make,就会在当前目录的.libs下生成插件动态库文件。

注意:在wireshark的文档中的readme.plugins文件中有讲怎么编译设置。


注意编译动态库的时候是在自己的目录下make。
在make的时候先要把此文件夹下的makefile和makefile.in修改正确。我的做法是将拷自别的文件夹下的makefile和makefile.in的关键字替换为自己文件夹 的关键字,然后再make。
这时又提示/bin/bash: @LIBTOOL@: command not found。
解决办法:apt-get install libtool,这样不能解决问题。
最后发现可以强行指定

 make LIBTOOL=libtool , make install LIBTOOL=libtool

注意等号两边都没有空格。

这样就可以解决这个问题了。
这时候又发现Makefile:862: .deps/packet-scoreboard.Plo: No such file or directory
我又将关键字scoreboard改回为原来的gryphon,这样最终进入到了真正的编译环节。

这样就会在当前目录下生成相应的scoreboard.la文件,并在.libs文件夹下生成scoreboard.so。这个.libs文件夹在正常的文件夹视图下看不到,在父目录中执行ls命令也看不到。但是可以cd ./libs。


这个是用软件中心自动安装时的wireshark安装目录的插件目录:/usr/lib/i386-linux-gnu/wireshark/libwireshark3/plugins/


当我们自己编译时wireshark的插件目录是:/usr/local/lib/wireshark/plugins/1.12.2,往这个目录考的时候把.la和.so文件都拷过去。这样我们的模块才会被调用。


通过命令wireshark /home/chenyang/wireshark_cap/qq.pcapng可以启动wireshark分析一个文件。