可以为 iPhone/armv6 编译 libpcap 吗? [英] Can libpcap be compiled for iPhone/armv6?

查看:27
本文介绍了可以为 iPhone/armv6 编译 libpcap 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译一个使用 pcap.h 的基本程序.我已经在我的 Mac OSX 机器上设置了环境,它使用 iPhone 3GS 的 iPhone 3.1.3 SDK.我还将 libpcap 安装到 ~/libpcap 以便我可以使用 -I 标志告诉 gcc 在哪里查找头文件.但是,它失败并显示 ld 警告,指出该文件不是所需的架构.

Trying to compile a basic program which uses pcap.h. I've set up the environment on my Mac OSX box which uses the iPhone 3.1.3 SDK for an iPhone 3GS. I've also installed libpcap to ~/libpcap so I can tell gcc where to look for the headers using the -I flag. However, it fails with an ld warning saying the file is not of the required architecture.

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

I'm compiling with the following line:

/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 选项没有帮助.我曾尝试为此在 Google 上搜索,但几乎没有.

I assume now that I need to recompile libpcap for the armv6 architecture (iPhone) but checking the ./configure options doesn't help. I've attempted to Google around for this but there is very little out there.

推荐答案

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

pcap.c isn't the source to libpcap, it's one of the source files to libpcap. You'd have to compile all the source files and build them into a library.

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

可能生成一个可以交叉编译 iOS 的 libpcap 的 Makefile.

might produce a Makefile that would cross-compile libpcap for iOS.

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

I presume you will be installing libpcap, or the application built using it, on a jailbroken iPhone, at least if you're going to be capturing packets, because you would need root access in order for libpcap to be able to open a BPF device in order to be able to capture.

这篇关于可以为 iPhone/armv6 编译 libpcap 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆