iOS - 文件是为存档而构建的,这不是正在链接的架构(i386)

发布于 2024-12-11 10:11:57 字数 346 浏览 0 评论 0原文

我有一些静态库想在我的 iPhone 应用程序中使用。当我尝试运行模拟器时,出现链接错误。 我是 iOS 开发新手,在链接之前构建的库时遇到了这个问题;

file was built for archive which is not the architecture being linked (i386)

这意味着我从这些库中引用的所有函数都给了我这样的结果:

undefined symbols for architectyre i386

我不确定要配置什么才能做到这一点。静态库是为armv7构建的,支持的平台为armv6、armv7。

I got a few static libraries I want to use in my iphone app. When I try to run the simulator I get linking errrors.
I am new to iOS development, and I ran into this problem when linking against libraries I built previously;

file was built for archive which is not the architecture being linked (i386)

Which means all the functions I reference from those libraries gives me this:

undefined symbols for architectyre i386

I am not sure what to configure to make this right. The static libraries are build for armv7, supporteed platforms armv6 armv7.

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

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

发布评论

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

评论(2

一腔孤↑勇 2024-12-18 10:11:57

我在为 iPad 构建的静态库中遇到了一个非常类似的错误。我相信我的解决方案是将“i386”添加到项目的体系结构设置中(单击项目 -> 构建设置 -> 体系结构 - 或者是有效的体系结构? - 然后单击“+”图标,输入突出显示的行中的“i386”)。任何能让你接近的人。

哦,还有一个警告,我读到我们也应该将“仅构建活动架构”设置为“否”。它已经为我设置好了,但你可能想检查一下。

I sorted a very similar error with a static library I was building for iPad. I believe my solution was to add "i386" to the Architectures setting for the project (Click on the Project -> Build Settings -> Architectures --or was it Valid Architectures?-- and click the '+' icon, type "i386" in the highlighted line). Anywho that should get you close.

Oh, one more caveat, I've read that we should set "Build Active Architecture Only" to "No" as well. It was already set for me, but that's something you might want to check.

岛歌少女 2024-12-18 10:11:57

在努力解决同样的问题并遵循更新构建设置、清除链接器搜索路径等所有已接受的答案之后。我终于发现了一个对我有用的答案。

在构建之前,请确保选择正确的类型(iPhone 模拟器)而不是 iOS 设备。然后重建。否则,您将尝试在模拟器 (i386) 上使用为 iOS 设备(arm 处理器)构建的库。本来应该是显而易见的,但事实并非如此。

之前:

iOS 设备设置

之后:

iPhone 5.1 Simulator Settings

现在,查看“导航器”中的“产品”组 >右键单击您的静态库(.a 文件)>在 Finder 中显示,您会注意到它位于 Debug-iphonesimulator 文件夹中,而不是 Debug-iphoneos 中。我本来并没有注意文件夹名称,或者我可能更早想到了这一点。

希望这有帮助。

After struggling with this same problem and following all the accepted answers of updating build settings, clearing the linker search path, etc.. I finally discovered an answer that worked for me.

Before building, make sure you select right type (iPhone Simulator) instead of iOS Device. Then rebuild. Otherwise, you're trying to use a library built for an iOS device (arm processor) on a simulator (i386). Should've been obvious, but wasn't.

Before:

iOS Device Settings

After:

iPhone 5.1 Simulator Settings

Now, look in the Products group in the Navigator > right click your static library (.a file) > Show in Finder, you'll notice that its in a Debug-iphonesimulator folder instead of Debug-iphoneos. I didn't pay any attention to the folder name originally, or I might have thought of this sooner.

Hope this helps.

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