libpcap编译
1. 执行./configure编绎libpcap出错
2. 如何将tcpmp移植到arm嵌入式系统
1.在http://www.tcpmp.org下载libpcap-0.9.8.tar.gz和tcpmp-3.9.8.tar.gz两个文件。
2.将这两个文件放在/home下解压。
3.编译,安装libpcap-0.9.8:
(1)进入libpcap目录,打开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
--host=arm-linux(如果不注释掉上面两段代码,可能会出现determine linux version when
cross-compiling或pcap type not determined when
cross-compiling导致无法configure)。运行开始的时候可能会出现个warning说不能用--host,configure的时候会自动识别交叉编译,但事实上不是这样,还是需要./configure
--host=arm-linux才会识别用什么交叉编译。
(2)配置之后,会生成Makefile。打开Makefile发现CC=arm-linux-gcc,说明交叉编译配置成功。但还需要把prefix项为prefix=/usr/local/arm/3.4.1/arm-linux。然后make,make
install。发现/usr/local/arm/3.4.1/arm-linux/include有了3个pcap文件,libpcap编译安装成功。
3.编译,安装tcpmp-3.9.8
(1)进入tcpmp目录,打开configure,将下面一段代码注释掉
# 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
--host=arm-linux
(2)打开生成的Makefile,将INCLS项改为INCLS=-I.-I./../libpcap-0.9.8
-I$(srcdir)/missing -I/usr/local/include,
DEFS项改为DEFS=-DHAVE_CONFIG_H -I./../libpcap-0.9.8
-I/usr/local/include
-I$(srcdir)missing -D_U="__attribute__((unused))"。
LDFLAGS=-L/usr/local/lib。然后make,make
install。在/usr/local/sbin下有个tcpmp的二进制文件,这个就是交叉编译成功的tcpmp
(3)将这个二进制文件放到tftpboot文件夹,用过tftp将这个文件下载到arm板上,chmod
777 tcpmp将其变为可执行文件。
(4)运行tcpmp,成功!
3. linux-2.4 如何安装 tcpmp
安装过程参照以下步骤:
1、打开网址:www.tcpmp.org/ 下载 libpcap-1.0.0.tar.gz (512.0KB) 软件包,通过命令 tar zxvf libpcap-1.0.0.tar.gz 解压文件,并将其放入自定义的安装目录。
2、打开网址:flex.sourceforge.net/ 下载 flex-2.5.35.tar.gz (1.40MB) 软件包,通过 tar zxvf flex-2.5.35.tar.gz 解压文件,并将其放入上述自定义的安装目录中。
注:如果没有编译安装此文件,在编译安装libpcap时,就会出现 “configure: error: Your operating system's lex is insufficient to compile libpcap.”的错误提示。
3、打开网址:ftp.gnu.org/gnu/bison/ 下载 bison-2.4.1.tar.gz (1.9MB) 软件包,通过 tar zxvf bison-2.4.1.tar.gz 解压文件,并将其放入上述自定义的安装目录中。
注:如果没有编译安装此文件,在编译安装libpcap时,就会出现 "configure: WARNING: don't have both flex and bison; reverting to lex/yacc checking for capable lex... insufficient" 的错误提示。
4、打开网址:ftp.gnu.org/gnu/m4/ 下载 m4-1.4.13.tar.gz (1.2MB)软件包,通过 tar zxvf m4-1.4.13.tar.gz 解压文件,并将其放入上述自定义的安装目录中。
注:如果没有编译安装此文件,在编译安装bison-2.4.1时,就会出现 “configure: error: GNU M4 1.4 is required”的错误提示。
5、而后依次进入目录m4-1.4.13,bison-2.4.1,flex-2.5.35,libpcap-1.0.0 并执行以下命令:
(sudo) ./configure
(sudo) make
(sudo) make install