我已经花了无数个小时对此感到困惑,使用 Google 搜索和其他 Stack Overflow 问题都无济于事。
我有一个 iPhone/iPad 通用应用程序,当目标是 armv6 时,它似乎编译得很好。但是,当设备是 iPad 时,我收到此警告:
警告:为 SDK 'Device - iPhone OS 3.2' 构建需要 armv7 架构。
奇怪的是,尽管有这个警告,该应用程序在 iPad 上仍然运行良好。但是,在这种情况下,我确实想以“正确的方式”做事。当我将目标架构切换到 armv7 时,出现链接错误:
“___restore_vfp_d8_d15_regs”,引用自:
*编辑*
“___save_vfp_d8_d15_regs”,引用自:
*编辑*
ld:未找到符号
collect2: ld 返回 1 个退出状态
错误的“编辑”部分是对我尝试链接的静态库的引用。
这是我从网上的许多建议中尝试过的。这些中的每一个都被多次建议而没有任何解释,这让我相信没有人完全理解这个问题:
"Never use the drop down menu in the upper left of the XCode window to choose the target. Instead, set this to Base SDK and then the Base SDK to iPhone OS 3.0 in the target configuration. Set the target device to your preferred target (iPad, iPhone OS 3.2 in my situation.)"
这会产生错误“未找到 -lcrt1.3.1.o 的库”
"Make sure that GCC isn't linking against the wrong version of the standard library. (You'll have to make sure the LIBRARY_SEARCH_PATH doesn't have the wrong path in it.)"
我的 LIBRARY_SEARCH_PATH 已经是空的,所以这似乎无关紧要。
"Try compiling with GCC 4.0 rather than GCC 4.2."
我在 UIKit 头文件中收到语法错误。错误是“'AT_NAME' 标记之前的语法错误。”该行是“UIKIT_EXTERN @interface UILocalizedIndexedCollation : NSObject”。
另一个项目使用相同的目标设置编译得很好,这真的让我怀疑我的理智。我可以处理损坏的 XCode 项目吗?
如果有人知道实际发生了什么并且有引用或不介意解释它,我将非常感激。
干杯!
最佳答案
ARMv7 和 ARMv6 之间的 VFP 有很多不同之处。在 ARMv7 中,通常最好使用 NEON。问题是您的静态库依赖于 ARMv6 中的 VFP - 您要么需要在 ARMv7 上编译库,要么将整个应用程序保持在 ARMv6 上。
恢复到 GCC 4.0 是愚蠢的 - ARMv7 支持在那时基本上不存在,除非 Apple 向后移植它。
关于定位 armv7 时出现 XCode 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2804953/