因為專案需要學 sniffit,而書上與網上的安裝說明多半只有一句「./configure && make,沒報錯就成功」。真實情況當然沒這麼順,這裡把我在 Ubuntu 上遇到的錯誤與解法記錄下來。
原本裝的是 16.04 LTS,結果 sniffit 裝不上、iNode 也裝不上,上網不便,只好換回 14.04 LTS。沒想到錯誤一樣多,所幸 iNode 順利裝好了。
網路上找到的批次安裝腳本可用,但裝完我找不到原始碼在哪,而且實際使用時只抓到 ICMP,因此決定回到原始碼編譯路線,目標版本 sniffit.0.3.7 Beta。
checking host/target/build system type ... Invalid configuration 'x86_64-pc-linux-gnu': machine 'x86_64-pc' not recognized
原因通常是缺少 libtool 提供的 config.guess 與 config.sub。先安裝:
sudo apt-get install libtool
再把它們複製進原始碼目錄:
sudo cp /usr/share/libtool/config/config.guess ~/download/sniffit.0.3.7.beta/ sudo cp /usr/share/libtool/config/config.sub ~/download/sniffit.0.3.7.beta/
重新執行 ./configure,雖然仍會印出 machine not recognized,但已不再中斷,能順利產生 Makefile。
make[1]: yacc: 命令未找到 /usr/bin/ld: 找不到 -lpcap collect2: error: ld returned 1 exit status
補齊編譯工具鏈與 bison:
sudo apt-get install build-essential sudo apt-get install bison
之後即可通過編譯。
嘗試第二種做法 bash fix_x86_64-unknown-linux-gnu.sh 時:
aclocal: 未找到命令 aclocal failed
安裝 automake(會一併帶入 autoconf):
sudo apt-get install automake
再執行則出現:
aclocal: warning: autoconf input should be named 'configure.ac' not 'configure.in' autoheader: error: AC_CONFIG_HEADERS not found in configure.in
這是老舊 configure.in 與新版 autoconf 不相容所致,需要把 configure.in 改名為 configure.ac 並補上 AC_CONFIG_HEADERS,我當時暫未繼續嘗試。
make clean 會把編譯好的 sniffit 一併刪掉,清理前請留意。整體裝完後執行仍出現「段錯誤(核心已轉儲)」,原因尚未查明,可能與封包抓取權限或 libpcap 版本有關,值得另開一輪排查。