環境:ArchLinux
源碼:libpcap
下面開始編譯libpcap,先將toolchain和staging_dir加入環境變量中
[form@Felicity libpcap]$ export PATH=$PATH:/home/form/K2_mt7620/PandoraBox-SDK-ralink-mt7620_gcc-4.8-linaro_uClibc-1.0.x.Linux-x86_64/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-1.0.x/bin
[form@Felicity libpcap]$ export STAGING_DIR=/home/form/K2_mt7620/PandoraBox-SDK-ralink-mt7620_gcc-4.8-linaro_uClibc-1.0.x.Linux-x86_64/staging_dir/:$STAGING_DIR
[form@Felicity libpcap]$ ./configure --host=mipsel-openwrt-linux --with-pcap=linux
checking build system type... x86_64-unknown-linux-gnu
checking host system type... mipsel-openwrt-linux-gnu
checking target system type... mipsel-openwrt-linux-gnu
checking for mipsel-openwrt-linux-gcc... mipsel-openwrt-linux-gcc
checking whether the C compiler works... no
configure: error: in `/home/form/K2_mt7620/libpcap':
configure: error: C compiler cannot create executables
See `config.log' for more details
配置錯誤,configure: error: C compiler cannot create executables。
錯誤原因分析
然後找到config.log截取其中的error段,找到具體的原因是缺libcloog-isl.so庫。
/home/form/K2_mt7620/PandoraBox-SDK-ralink-mt7620_gcc-4.8-linaro_uClibc-1.0.x.Linux-x86_64/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-1.0.x/bin/../libexec/gcc/mipsel-openwrt-linux-uclibc/4.8.3/cc1: error while loading shared libraries: libcloog-isl.so.4: cannot open shared object file: No such file or directory
下面把cloog和isl庫裝上,包名可在https://aur.archlinux.org/packages/上找。
[form@Felicity libpcap]$ yaourt -S cloog
[form@Felicity libpcap]$ yaourt -S isl
提示:ukylin可以使用apt-get install libcloog-isl-dev命令來安裝
再執行配置./configure還是報同樣的錯誤,此時打開config.log截取error段,此時還是提示缺isl
/home/form/K2_mt7620/PandoraBox-SDK-ralink-mt7620_gcc-4.8-linaro_uClibc-1.0.x.Linux-x86_64/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-1.0.x/bin/../libexec/gcc/mipsel-openwrt-linux-uclibc/4.8.3/cc1: error while loading shared libraries: libisl.so.10: cannot open shared object file: No such file or directory
在/usr/lib/目錄可以找到libisl.so.15.3.0庫文件是存在的,而且還有libisl.so和libisl.so.15兩個軟鏈接,但在配置時仍然提示找不到libisl.so.10。
解決方案
將libisl.so.10也通過軟鏈接到libisl.so.15.3.0庫上。
[form@Felicity libpcap]$ sudo ln -s /usr/lib/libisl.so.15.3.0 /usr/lib/libisl.so.10
此時再執行配置
[form@Felicity libpcap]$ ./configure –host=mipsel-openwrt-linux –with-pcap=linux
checking build system type… x86_64-unknown-linux-uclibc
checking host system type… mipsel-openwrt-linux-gnu
checking target system type… mipsel-openwrt-linux-gnu
checking for mipsel-openwrt-linux-gcc… mipsel-openwrt-linux-gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… yes……中間省略……
config.status: creating Makefile
config.status: creating rpcapd/Makefile
config.status: creating config.h
config.status: executing default-1 commands[form@Felicity libpcap]$ make
……中間省略……
config.status: creating pcap-config.tmp
mv pcap-config.tmp pcap-config[form@F3licity libpcap]$ find . -name “*.a”
./libpcap.a
編譯通過~
參考:
http://blog.csdn.net/lvshaorong/article/details/62215033
http://www.right.com.cn/forum/forum.php?mod=viewthread&tid=251362&page=1#pid2067470