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