可以为iPhone / armv6编译libpcap吗?

时间:2010-06-18 15:36:52

标签: iphone architecture libpcap tcpdump armv6

尝试编译使用pcap.h的基本程序。我已经在我的Mac OSX盒子上设置了环境,该盒子使用适用于iPhone 3GS的iPhone 3.1.3 SDK。我还安装了libpcap到〜/ libpcap,所以我可以告诉gcc使用-I标志查找标头的位置。但是,它失败并显示ld警告说该文件不是所需的体系结构。

我正在使用以下行进行编译:

/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc -I /Users/abnev/libpcap/include -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -o pcap pcap.c -lpcap

生成错误的是:

ld: warning: in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk/usr/lib/libpcap.dylib, file is not of required architecture
Undefined symbols:
  "_pcap_geterr", referenced from:
      _main in ccOL3e0B.o
      _main in ccOL3e0B.o
  "_pcap_open_live", referenced from:
      _main in ccOL3e0B.o
  "_pcap_next", referenced from:
      _main in ccOL3e0B.o
  "_pcap_lookupdev", referenced from:
      _main in ccOL3e0B.o
  "_pcap_setfilter", referenced from:
      _main in ccOL3e0B.o
  "_pcap_lookupnet", referenced from:
      _main in ccOL3e0B.o
  "_pcap_close", referenced from:
      _main in ccOL3e0B.o
  "_pcap_compile", referenced from:
      _main in ccOL3e0B.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

我现在假设我需要为armv6架构(iPhone)重新编译libpcap,但检查./configure选项并没有帮助。我试图谷歌周围,但没有那么多。

1 个答案:

答案 0 :(得分:4)

pcap.c不是libpcap的源代码,它是一个源文件到libpcap。您必须编译所有源文件并将它们构建到库中。

否则

CFLAGS="-I /Users/abnev/libpcap/include -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk" ./configure

可能生成一个Makefile,它将为iOS交叉编译libpcap。

我认为你将在越狱的iPhone上安装libpcap或使用它构建的应用程序,至少如果你要捕获数据包,因为你需要root访问才能使libpcap能够打开一个BPF设备,以便能够捕获。