我如何构建这个静态 C 库以与 iPhone 一起使用

发布于 2024-11-03 20:20:09 字数 1063 浏览 1 评论 0原文

我一直在尝试为 iPhone 项目构建一个 C 库。该库是通过 Makefile 提供给我的。当我通过简单地运行 make 并将静态库添加到我的项目来构建库时,链接器抱怨该库是为 x86_64 架构构建的,无法链接到 i386。

所以..我编辑了 make 文件来构建 i386 的库。该项目现在编译和链接没有问题,但应用程序由于以下原因终止:

检测到调用 iPhone 上不存在的系统库中的符号的尝试:从图像 KadeChat 中的函数 irc_connect 调用的 fcntl$UNIX2003。如果您在 gdb 中运行模拟器二进制文件时遇到此问题,请确保首先“设置 start-with-shell off”。

我对此做了很多谷歌搜索,看来这可能是我的 SDK 版本的一个错误(但我不确定)。

所以..我想在设备上运行这个应用程序,因为显然模拟器将无法工作。问题是我无法为目标架构构建这个库。

文件是为不受支持的文件构建的 格式不是架构 正在链接(armv7)

我再次编辑了 make 文件,尝试为设备的目标架构构建库。

我在 Makefile 中进行了以下编辑:

CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang CFLAGS = -Wall -DIN_BUILDING_LIBIRC -O3 -DENABLE_THREADS -D_REENTRANT -arch armv7

这会导致以下错误:

/usr/include/machine/_types.h:36:10: fatal error: 'arm/_types.h' 文件未找到#include "arm/_types.h"

正如你所看到的,我没有运气让这个库为我工作。由于我是 iPhone 开发新手,我想我只想问一下。将 C 库移植到 iPhone 上的最佳方法是什么?我应该尝试直接在我的项目中构建源代码吗?我尝试过这样做,但导致了很多错误。任何建议都会有帮助。

谢谢!

I have been trying to get a C library built for an iPhone project. The library is provided to me with a Makefile. When I build the library by simply running make and adding the static lib to my project the linker complains that this library was build for the x86_64 architecture and cannnot be linked to i386.

So.. I edited the make file to build the library for the i386. The project now compiles and links without a problem but the application terminates due to:

Detected an attempt to call a symbol in system libraries that is not present on the iPhone: fcntl$UNIX2003 called from function irc_connect in image KadeChat. If you are encountering this problem running a simulator binary within gdb, make sure you 'set start-with-shell off' first.

I did a lot of googling about this and it seems that this might be a bug with my version of the SDK (but im not sure).

So.. I want to run this application on the device since, apparently, the simulator will not work. The problem with this is that I cannot get this library build for the target architecture.

file was built for unsupported file
format which is not the architecture
being linked (armv7)

I edited the make file again to try and build the library for the device's target architecture.

I made the following edits in the Makefile:

CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang
CFLAGS = -Wall -DIN_BUILDING_LIBIRC -O3 -DENABLE_THREADS -D_REENTRANT -arch armv7

This results in the following error:

/usr/include/machine/_types.h:36:10: fatal error: 'arm/_types.h' file not found #include "arm/_types.h"

As you can see I am not having any luck with getting this library to work for me. Since I am new to iPhone development I thought I would just ask. What is the best way to deal with porting a C library to work with the iPhone? Should I try and build the source directly in my project?? I have attempted this but it resulted in many errors. Any advice would be helpful.

Thanks!

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

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

发布评论

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

评论(1

在风中等你 2024-11-10 20:20:09

与其尝试使用 Makefile 手动进行正确的设置来交叉编译,不如像您所说的那样,将库的源代码直接包含到您的项目中。

如果这导致“许多错误”,可能是您丢失了一些 .h 文件,或者 Makefile 设置了一些您未在 XCode 中提供的“-D”编译器标志。

Rather than hacking around trying to get the settings right to cross-compile things manually using a Makefile, perhaps the simplest thing to do would be to include the source of the library directly into your project as you say.

If this resulted in "many errors", perhaps you're missing some .h files, or the Makefile is setting some "-D" compiler flags that you're not providing in XCode.

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