Chinaunix首页 | 论坛 | 博客
  • 博客访问: 290844
  • 博文数量: 71
  • 博客积分: 30
  • 博客等级: 民兵
  • 技术积分: 217
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-31 15:43
文章分类

全部博文(71)

文章存档

2016年(4)

2015年(2)

2014年(2)

2013年(63)

分类: LINUX

2014-04-10 10:55:11

1、下载libpcap-0.9.8.tar.gztcpdump-3.9.8.tar.gz两个文件。(或上面发布的最新的文件)

2、解压。将文件拷入虚拟ubuntu系统

3、进入虚拟机ubuntu系统

4、进入libpcap-1.0.0目录,先终端将PATH环境变量做一个修改:
1)export PATH=/projects/hnd/tools/linux/hndtools-mipsel-linux-uclibc-4.2.3/bin:$PATH
/projects/hnd/tools/linux/hndtools-mipsel-linux-uclibc-4.2.3/bin是交叉编译工具存放的地方(当然也可以在.barhrc中添加)
2) 再执行./configure--host= mipsel-uclibc-linux26时会出现了一个错误: 
[root@olive libpcap-0.9.4]# ./configure --host=mipsel-uclibc-linux26
                       .........  
  configure: error: pcap type not determined when cross-compiling; use --with-pcap=...

运行configure说交叉编译时没指定pcap类型,采取暴力措施了,在configure脚本中注释掉检查交叉编译的部分,具体注释掉一下语句:vim configure
   #if test -z "$with_pcap" && test "$cross_compiling" = yes; then
    # { { echo "$as_me:$LINENO: error: pcap type not determined when cross-compiling; use --with-pcap= ..." >&5

    #echo "$as_me: error: pcap type not determined when cross-compiling; use --with-pcap=..." >&2;}
    #   { (exit 1); exit 1; }; }

    #fi  

     #  if test $ac_cv_linux_vers = unknown ;then

     #   { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5

     #echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}#

        { (exit 1); exit 1; }; }

     #  fi

 再次运行configure命令,这下终于OK!终于生成了Makefile.接下来make:  

居然没生成动态链接库,只有一个libpcap.a静态库.只好再修改它的Makefile.打开Makefile,找到了下面这个目标:

从新make,执行如:make libpcap.so即可生成该动态文件libpcap.so.1.0.0

编译tcpdump

然后去到tcpdump-4.2.1下面,也是先
1)export PATH=/projects/hnd/tools/linux/hndtools-mipsel-linux-uclibc-4.2.3/bin:$PATH

2)打开configure文件修改如下

linux*)
 { echo "$as_me:$LINENO: checking Linux kernel version" >&5
echo $ECHO_N "checking Linux kernel version... $ECHO_C" >&6; }
  if test "$cross_compiling" = yes; then
   if test "${ac_cv_linux_vers+set}" = set; then
  echo $ECHO_N "(cached) $ECHO_C" >&6
else
  ac_cv_linux_vers=2.6
fi

3) 再执行./configure--host= mipsel-uclibc-linux26 ,生成Makefile (如果生成过程当中出现了错误,可以回到libpcap目录下执行make install命令)。

打开生成的Makefie,找到如下:


发现将libpcap-1.0.0定义在了该目录的上一个目录。

4)执行make即可。

最后生成了tcpdump文件,用file命令查看如下:

tcpdump: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked (uses shared libs), not stripped

最后通过tftp命令将文件传到板子上去


阅读(3832) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~