为 iPhone 编译 C lib

发布于 2024-09-17 05:52:43 字数 1189 浏览 3 评论 0原文

我正在尝试编译 ZeroMQ C 绑定以便能够在 iPhone 上使用它,这是我的配置选项:

./configure --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc -4.2.1 CFLAGS="-pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.1。 2 -gdwarf-2 -mthumb -I/Library/iPhone/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -mdynamic-no-pic" CPP=/Developer/Platforms/iPhoneOS .platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/Developer /Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib 它

实际上配置和编译得很好,但是当我将它添加到 Xcode Frameworks 部分时,我收到警告: ld: warning: in /path/to/app/libzmq.a, file wasbuilt for unsupported file格式不是正在链接的体系结构(armv7),并且有很多符号未找到错误。

如果我将当前活动架构从armv6更改为armv7,警告消息会将其更改为armv6。 我做错了什么?

谢谢, 担

I'm trying to compile ZeroMQ C binding in order to be able to use it on iPhone, here is my configure options:


./configure --host=arm-apple-darwin --enable-static=yes --enable-shared=no CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 CFLAGS="-pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=3.1.2 -gdwarf-2 -mthumb -I/Library/iPhone/include -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.0.sdk -mdynamic-no-pic" CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp AR=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ar AS=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as LIBTOOL=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool STRIP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/strip RANLIB=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ranlib

It actually configures and compiles fine, but when I add it to Xcode Frameworks section, I get warning: ld: warning: in /path/to/app/libzmq.a, file was built for unsupported file format which is not the architecture being linked (armv7) and a lot of symbol not found errors.

If I change current active architecture from armv6 to armv7, warning message will change it to armv6.
What am I doing wrong ?

Thanks,
Dan

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

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

发布评论

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

评论(2

紙鸢 2024-09-24 05:52:43

听起来您正在为 iPhone 构建通用的 armv6/armv7 二进制文件(这是默认设置,所以这是有道理的)。这意味着您需要构建一个通用库来链接。构建两个库,然后使用lipo将两者结合起来。

例如,构建armv6 并将其放置在armv6/libfoo.a 中,将armv7 放置在armv7/libfoo.a 中。然后运行

lipo -arch armv6 armv6/libfoo.a -arch armv7 armv7/libfoo.a -output libfoo.a -create

创建通用库libfoo.a

It sounds like you're building a universal armv6/armv7 binary for the iPhone (this is the default, so that makes sense). That means that you need to build a universal library to link against. Build both libraries, and then use lipo to combine the two.

For example, build the armv6 one and place it at armv6/libfoo.a, and the armv7 one at armv7/libfoo.a. Then run

lipo -arch armv6 armv6/libfoo.a -arch armv7 armv7/libfoo.a -output libfoo.a -create

to create the universal library libfoo.a.

攀登最高峰 2024-09-24 05:52:43

鉴于来自 ld 的警告消息,我的猜测是您没有为正确的平台编译该库。考虑到您正在使用 configure,我的猜测是您正在尝试在 Xcode 之外编译该库,然后稍后将其引入 Xcode 中以链接它。

也许您可以尝试运行 configure 来设置你的头文件,但是在 Xcode 中执行实际的编译步骤吗?

这里有很多关于编译第三方(外部)C 或 C++ 库以在 iPhone 项目中使用的相关问题。

为 iPhone 创建静态库

TiMidity:需要帮助为 iPhone 编译此库

Given the warning message from ld, my guess is you're not compiling the library for the correct platform. And given you're using configure, my guess is you're trying to compile the library outside of Xcode and then bring it into Xcode later to link it in.

Perhaps you could try running configure to set up your headers, but do the actual compilation step inside Xcode?

There are lots of related questions here on SO about compiling third-party (external) C or C++ libraries for use in iPhone projects.

Creating static library for iPhone

TiMidity: need help compiling this library for the iPhone

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