可以为 iPhone/armv6 编译 libpcap 吗?

发布于 2024-09-06 08:17:15 字数 1317 浏览 5 评论 0原文

尝试编译一个使用 pcap.h 的基本程序。我已经在我的 Mac OSX 机器上设置了环境,该机器使用适用于 iPhone 3GS 的 iPhone 3.1.3 SDK。我还将 libpcap 安装到 ~/libpcap,这样我就可以使用 -I 标志告诉 gcc 在哪里查找标头。但是,它失败并显示 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选项没有帮助。我曾尝试用谷歌搜索这方面的内容,但几乎没有。

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

Error's being generated are:

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

佼人 2024-09-13 08:17:15

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

这样做

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

可能会生成一个为 iOS 交叉编译 libpcap 的 Makefile。

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

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.

Doing

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文