[关闭]
@natsumi 2016-11-28T07:27:09.000000Z 字数 10371 阅读 2964

CentOS 6.5 安装Wireshark-2.0.*

Wireshark Linux


主要流程参考ubuntu下的安装过程
https://www.zybuluo.com/natsumi/note/70150

装了好多天终于装上了
写的结构太混乱= =

1. configure过程

1.1 Qt is not available

ubuntu下安装的时候直接sudo apt-get install libqt4-dev
类似的可以在网上查到类似的yum自动安装的方法
yum install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
但是yum安装的是4.6.2,而wireshark最低要求是4.7.0

rpm包安装的话需要解决比较复杂的包依赖问题

现在尝试源码编译安装qt
qt各种版本下载地址:http://download.qt.io/
这里选择4.8.7,下载页面:http://download.qt.io/official_releases/qt/4.8/4.8.7/
在这里下载qt-everywhere-opensource-src-4.8.7.tar.gz
先运行./configure
然后我选择了opensource edition,同意各种协议
configure完成后会有提示,重新configure和编译安装的方法

gmake编译
服务器编译了25分钟左右,报错

  1. gmake[2]: Leaving directory `/home/xietianrui/qt-everywhere-opensource-src-4.8.7/src/3rdparty/webkit/Source/JavaScriptCore'
  2. cd WebCore/ && /home/xietianrui/qt-everywhere-opensource-src-4.8.7/bin/qmake /home/xietianrui/qt-everywhere-opensource-src-4.8.7/src/3rdparty/webkit/Source/WebCore/WebCore.pro -spec /home/xietianrui/qt-everywhere-opensource-src-4.8.7/mkspecs/linux-g++ -o Makefile.WebKit
  3. Project ERROR: Package gstreamer-app-0.10 not found
  4. gmake[1]: *** [WebCore/Makefile.WebKit] 错误 2
  5. gmake[1]: Leaving directory `/home/xietianrui/qt-everywhere-opensource-src-4.8.7/src/3rdparty/webkit/Source'
  6. gmake: *** [sub-webkit-make_default-ordered] 错误 2

参考下面文章
http://blog.csdn.net/yinjiabin/article/details/7656173
yum install gstreamer-plugins-base-devel

然后再gmake,又编译了1小时20分钟左右

然后root用户gmake install
应该不会出什么问题了吧
五分钟左右完成了~

编辑.profile文件vim /etc/profile
在最后添加

  1. export QT_HOME=/usr/local/Trolltech/Qt-4.8.7/bin
  2. export PATH=$QT_HOME:$PATH

这两句。
然后source /etc/profile让修改生效
然后designer就可以打开qt

之后再configure还是不行

1.1.1 方法1放弃Qt

试过在/etc/ld.so.conf.d里创建一个文件,把目录/usr/local/Trolltech/Qt-4.8.7/lib加到这个文件里,但还是不行啊==

最后发现qt是optional package
可以./configure --with-qt=no --with-gtk2=yes --with-gtk3=no

但是其实还是QT好装,这三个不能都不带,所以还是不建议放弃QT~

1.1.2 方法2(真的解决了这个问题!!!)

blog.csdn.net/langeldep/article/details/6804331
参考这个
在qt源码目录下找到./lib/pkgconfig/*.pc全部拷贝到\usr\lib64\pkgconfig目录下
或者找到安装目录下*.pc文件的位置,将该目录添加到PKG_CONFIG_PATH环境变量中,即在/etc/profile文件最后加上以下内容

  1. export PCRE_PC=/usr/local/lib/pkgconfig
  2. export QT_PC=/usr/local/Trolltech/Qt-4.8.7/lib/pkgconfig
  3. export PKG_CONFIG_PATH=$QT_PC:$PCRE_PC

source /etc/profile使修改生效
再configure

1.2 源码安装libpcap

下载地址:http://www.tcpdump.org/release/
解压软件包: tar -zxvf libpcap-1.7.4.tar.gz
进入解压后的目录,输入命令

  1. ./configure
  2. make
  3. make install

2. 编译wireshark

configure过了之后就make
报错了

  1. make[2]: Entering directory `/home/xietianrui/wireshark-2.0.2/ui/gtk'
  2. CC libgtkui_a-rtp_player.o
  3. rtp_player.c: 在函数‘channel_draw’中:
  4. rtp_player.c:1350:24: 错误:‘rtp_channel_info_t’没有名为‘start_time’的成员
  5. rtp_player.c:1350:61: 错误:‘rtp_channel_info_t’没有名为‘start_time’的成员
  6. rtp_player.c:1457:66: 错误:‘rtp_channel_info_t’没有名为‘start_time’的成员
  7. make[2]: *** [libgtkui_a-rtp_player.o] 错误 1
  8. make[2]: Leaving directory `/home/xietianrui/wireshark-2.0.2/ui/gtk'
  9. make[1]: *** [all-recursive] 错误 1
  10. make[1]: Leaving directory `/home/xietianrui/wireshark-2.0.2'
  11. make: *** [all] 错误 2

2.1 装gtk+-3.*

上面的错误
感觉跟gtk用的是2有关系
先装个gtk+-3.*试试
下载:http://ftp.acc.umu.se/pub/gnome/sources/gtk+/
我选了最新的3.21.1
下载.tar.xz的包~
解压:这个压缩包也是打包后再压缩,外面是xz压缩方式,里层是tar打包方式。
$ xz -d ***.tar.xz
$ tar -xvf ***.tar

gtk+-3的configure又错了==

  1. configure: error: Package requirements (glib-2.0 >= 2.45.8 atk >= 2.15.1 pango >= 1.37.3 cairo >= 1.14.0 cairo-gobject >= 1.14.0 gdk-pixbuf-2.0 >= 2.30.0) were not met:
  2. Requested 'glib-2.0 >= 2.45.8' but version of GLib is 2.22.5
  3. Requested 'atk >= 2.15.1' but version of Atk is 1.28.0
  4. Requested 'pango >= 1.37.3' but version of Pango is 1.28.1
  5. Requested 'cairo >= 1.14.0' but version of cairo is 1.8.8
  6. No package 'cairo-gobject' found
  7. Requested 'gdk-pixbuf-2.0 >= 2.30.0' but version of GdkPixbuf is 2.18.9
  8. Consider adjusting the PKG_CONFIG_PATH environment variable if you
  9. installed software in a non-standard prefix.
  10. Alternatively, you may set the environment variables BASE_DEPENDENCIES_CFLAGS
  11. and BASE_DEPENDENCIES_LIBS to avoid the need to call pkg-config.
  12. See the pkg-config man page for more details.

2.1.1 装最新glib

下载:http://ftp.acc.umu.se/pub/GNOME/sources/glib/

./configure 时可能出现缺少zlib和libffi版本太小的问题

zlib的解决:
在ubuntu下apt-get inastall zlib-devel
在centos下使用yum install zlib-devel

对于libffi相应的提示是
configure: error: Package requirements (libffi >= 3.0.0) were not met:
No package 'libffi' found
直接yum install libffi-devel

报错again= =

  1. configure: error: Package requirements (libpcre >= 8.13) were not met:
  2. No package 'libpcre' found
  3. Consider adjusting the PKG_CONFIG_PATH environment variable if you
  4. installed software in a non-standard prefix.
  5. Alternatively, you may set the environment variables PCRE_CFLAGS
  6. and PCRE_LIBS to avoid the need to call pkg-config.
  7. See the pkg-config man page for more details.

完成2.1.1.1后
./configure --prefix=/usr --libdir=/usr/lib64
make
make install

2.1.1.1 安装pcre

yum安装的pcre都是7.8版本,不符合要求
于是手动安装
下载:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
解压:tar -zxvf pcre-8.38.tar.gz
然后还是configure make make install
但是安装完后重新到glib中进行configure,会报错

  1. configure: error: *** The system-supplied PCRE does not support Unicode properties or UTF-8.

参考http://www.linuxfromscratch.org/blfs/view/svn/general/pcre.html
还是不对= =

  1. patch -Np1 -i ../pcre-8.38-upstream_fixes-1.patch &&
  2. ./configure --prefix=/usr \
  3. --docdir=/usr/share/doc/pcre-8.38 \
  4. --libdir=/usr/lib64 \
  5. --enable-unicode-properties \
  6. --enable-pcre16 \
  7. --enable-pcre32 \
  8. --enable-pcregrep-libz \
  9. --enable-pcregrep-libbz2 \
  10. --enable-pcretest-libreadline \
  11. --disable-static &&
  12. make

然后make install就行了

2.1.2 安装atk

atk要求2.15.1以上
atk的包好难找到
选择尝试完全不带gtk去configure
但是这还是需要glib的~所有我们前面的glib并没有白装~

2.2 configure wireshark without gtk

./configure --with-gtk2=no --with-gtk3=no
然后出现了类似这样的报错,忘记拷下来了

  1. checking for GLIB - version >= 2.5.7...
  2. *** 'pkg-config --modversion glib-2.0' returned 2.12.0, but GLIB (2.10.3)
  3. *** was found! If pkg-config was correct, then it is best
  4. *** to remove the old version of GLib. You may also be able to fix the error
  5. *** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
  6. *** /etc/ld.so.conf. Make sure you have run ldconfig if that is
  7. *** required on your system.
  8. *** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH
  9. *** to point to the correct configuration files
  10. no
  11. configure: error:
  12. *** GLIB 2.5.7 or better is required. The latest version of
  13. *** GLIB is always available from ftp://ftp.gtk.org/. If GLIB is installed
  14. *** but not in the same location as pkg-config add the location of the file
  15. *** glib-2.0.pc to the environment variable PKG_CONFIG_PATH.

这应该是新版覆盖了旧版的部分文件,但是没有完全覆盖,也就是旧版没卸干净导致的
我的解决方法如下

2.2.1 调整glib安装位置

网上的方法一般是先将新版卸掉make uninstall,在查找系统中其他glib2相关的文件,删除
但是这删除系统目录下libgio-2.0.so libglib-2.0.so libgmodule-2.0.so libgobject-2.0.so libgthread-2.0.so这类文件会导致系统出现问题,比如我将/lib64目录下的这些软链接和实际的库文件mv到某个用户的主目录下后,su命令执行会报段错误

这并不是一种安全的方法
但是经过查找我们发现glib2旧版残留主要在/lib64目录下,没有被覆盖
这说明我们configure时设置的libdir是不对的(之前用的是默认),设置到/lib64就可以覆盖库文件

进入glib2源码包目录,将新版make uninstall之后,用下面的选项重新configure
./configure --prefix=/usr --libdir=/lib64
然后(最好先make clean一下,不然安装过程可能会报错,参考http://www.2cto.com/os/201207/141888.htmlmakemake install
这时候在查看/lib64目录下的相关库文件和软链接,可以看到软链接都指向新版本的库文件,两个版本的库文件同时存在~

  1. [xietianrui@ibm1 ~]$ ll /lib64/libg*-2.0.so*
  2. lrwxrwxrwx. 1 root root 22 5 12 10:18 /lib64/libgio-2.0.so -> libgio-2.0.so.0.4800.1
  3. lrwxrwxrwx. 1 root root 22 5 12 10:18 /lib64/libgio-2.0.so.0 -> libgio-2.0.so.0.4800.1
  4. -rwxr-xr-x. 1 root root 698064 6 22 2012 /lib64/libgio-2.0.so.0.2200.5
  5. -rwxr-xr-x. 1 root root 8391457 5 12 10:18 /lib64/libgio-2.0.so.0.4800.1
  6. lrwxrwxrwx. 1 root root 23 5 12 10:18 /lib64/libglib-2.0.so -> libglib-2.0.so.0.4800.1
  7. lrwxrwxrwx. 1 root root 23 5 12 10:18 /lib64/libglib-2.0.so.0 -> libglib-2.0.so.0.4800.1
  8. -rwxr-xr-x. 1 root root 939360 6 22 2012 /lib64/libglib-2.0.so.0.2200.5
  9. -rwxr-xr-x. 1 root root 4110587 5 12 10:18 /lib64/libglib-2.0.so.0.4800.1
  10. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgmodule-2.0.so -> libgmodule-2.0.so.0.4800.1
  11. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgmodule-2.0.so.0 -> libgmodule-2.0.so.0.4800.1
  12. -rwxr-xr-x. 1 root root 14392 6 22 2012 /lib64/libgmodule-2.0.so.0.2200.5
  13. -rwxr-xr-x. 1 root root 47805 5 12 10:18 /lib64/libgmodule-2.0.so.0.4800.1
  14. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgobject-2.0.so -> libgobject-2.0.so.0.4800.1
  15. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgobject-2.0.so.0 -> libgobject-2.0.so.0.4800.1
  16. -rwxr-xr-x. 1 root root 283584 6 22 2012 /lib64/libgobject-2.0.so.0.2200.5
  17. -rwxr-xr-x. 1 root root 1561667 5 12 10:18 /lib64/libgobject-2.0.so.0.4800.1
  18. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgthread-2.0.so -> libgthread-2.0.so.0.4800.1
  19. lrwxrwxrwx. 1 root root 26 5 12 10:18 /lib64/libgthread-2.0.so.0 -> libgthread-2.0.so.0.4800.1
  20. -rwxr-xr-x. 1 root root 19920 6 22 2012 /lib64/libgthread-2.0.so.0.2200.5
  21. -rwxr-xr-x. 1 root root 9619 5 12 10:18 /lib64/libgthread-2.0.so.0.4800.1

2.2.2 重新configure wireshark

再用这个不带gtk的选项configure一次
./configure --with-gtk2=no --with-gtk3=no

一切正常~
然后make~
不make install也可以,进入源码目录
./wireshark就可以运行

2.3 make过程可能出现的问题

之前装了若干遍没有出过这个问题
看这个报错应该是这台机器上装了qt-4.6.2,由于是yum安装,卸载时会卸掉所有依赖他的包,所以并没有卸载,直接在上面装了qt-4.8.7,但是编译的时候用错了

  1. CC libqtui_a-wireshark-tap-register.o
  2. /usr/bin/moc-qt4 -I.. -I../.. -o about_dialog.moc.cpp about_dialog.h
  3. CXX about_dialog.moc.o
  4. about_dialog.moc.cpp:14:2: 错误:#error "This file was generated using the moc from 4.6.2. It"
  5. about_dialog.moc.cpp:15:2: 错误:#error "cannot be used with the include files from this version of Qt."
  6. about_dialog.moc.cpp:16:2: 错误:#error "(The moc has changed too much.)"
  7. make[2]: *** [about_dialog.moc.o] 错误 1
  8. make[2]: Leaving directory `/home/xietianrui/wireshark-2.0.2-cmd/ui/qt'
  9. make[1]: *** [all-recursive] 错误 1
  10. make[1]: Leaving directory `/home/xietianrui/wireshark-2.0.2-cmd'
  11. make: *** [all] 错误 2

解决方法:
看configure脚本

  1. #
  2. # Annoyingly, on some Linux distros (e.g. Debian)
  3. # the Qt 5 tools have no suffix and the Qt 4 tools
  4. # have suffix -qt4. On other distros (e.g. openSUSE)
  5. # the Qt 5 tools have suffix -qt5 and the Qt 4 tools
  6. # have no suffix.
  7. #
  8. # So we check for the tool first with the -qtN suffix
  9. # and then with no suffix.
  10. #
  11. for ac_prog in moc-qt$qt_version moc
  12. ... ...

就是说虽然qt的版本满足要求,但是在选用qt的组件时,configure脚本根据命名来寻找,误选了低版本的组件moc-qt4.6.2,高版本qt默认安装在/usr/local/Trolltech/Qt-4.8.7目录下,并没有在组件名称上携带版本号。修改下查找顺序即可,先找不带版本号的,就可以找到高版本的了。

  1. for ac_prog in moc moc-qt$qt_version

另外还有rcc、uic两个组件也需要修改查找顺序,在脚本中搜索uic-qt$qt_versionrcc-qt$qt_version即可找到。
修改保存后,重新configure,可以看到如下的输出,说明已经找到正确的qt组件

  1. checking for qtchooser... no
  2. checking for uic... /usr/local/Trolltech/Qt-4.8.7/bin/uic
  3. checking for qtchooser... no
  4. checking for moc... /usr/local/Trolltech/Qt-4.8.7/bin/moc
  5. checking for qtchooser... no
  6. checking for rcc... /usr/local/Trolltech/Qt-4.8.7/bin/rcc

之后make clean再重新make即可

3. 运行wireshark

当切换到root用户运行wireshark时窗口打开一片空白,终端中报错

  1. X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  2. Major opcode: 62 (X_CopyArea)
  3. Resource id: 0x3800019

参考这里的第二个回答:
http://stackoverflow.com/questions/12829402/qt-errors-after-static-compilation

Warning: X Error: BadDrawable (invalid Pixmap or Window parameter)是qt应用程序的常见错误
在这里有KDE桌面环境的解决方案:http://www.iwillfolo.com/quick-fix-one-kdes-common-xorg-errors-x-error-baddrawable/
服务器上的centOS装的是gnome桌面环境,也是亲测有效的!
export QT_X11_NO_MITSHM=1
或者QT_X11_NO_MITSHM=1 yourapp
意思是禁止Qt使用MIT-SHM X11扩展

把这句话export QT_X11_NO_MITSHM=1写在/etc/profile中,然后source /etc/profile但是只在当前终端中有效,在其他终端中都无效。
参考http://forum.ubuntu.org.cn/viewtopic.php?t=246185
想到之前用root修改并执行/etc/profile文件都是用自己用户名远程登录后,su到root用户。于是直接root远程登录了一次,问题。。。。。。还是并没有解决

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注