定位 armv7 时 XCode 链接错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2804953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCode linking error when targeting armv7
提问by Tom
I've already spent countless hours puzzling over this, utilizing Google searches and other Stack Overflow questions to no avail.
我已经花了无数个小时对此感到困惑,使用 Google 搜索和其他 Stack Overflow 问题都无济于事。
I have an iPhone/iPad universal application, which seems to compile fine when the target is armv6. However, when the device is iPad, I get this warning:
我有一个 iPhone/iPad 通用应用程序,当目标是 armv6 时,它似乎可以很好地编译。但是,当设备是 iPad 时,我收到此警告:
warning: building for SDK 'Device - iPhone OS 3.2' requires an armv7 architecture.
Oddly enough, the app still runs great on iPad in spite of this warning. However, I do want to do things the "right way" what ever that means in this case. When I switch the target architecture to armv7, I get linking errors:
奇怪的是,尽管有这个警告,该应用程序在 iPad 上仍然运行良好。但是,在这种情况下,我确实想以“正确的方式”做事。当我将目标架构切换到 armv7 时,出现链接错误:
"___restore_vfp_d8_d15_regs", referenced from: *redacted* "___save_vfp_d8_d15_regs", referenced from: *redacted* ld: symbol(s) not found collect2: ld returned 1 exit status
The "redacted" portions of the errors are references to the static library to which I'm trying to link.
错误的“编辑”部分是对我尝试链接的静态库的引用。
Here's what I've tried from the many suggestions online. Each of these were suggested more than once without any explanation, which leads me to believe nobody quite understands this problem:
这是我从网上的许多建议中尝试过的。这些中的每一个都被多次建议而没有任何解释,这让我相信没有人完全理解这个问题:
"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.)"
“永远不要使用 XCode 窗口左上角的下拉菜单来选择目标。相反,在目标配置中将其设置为 Base SDK,然后将 Base SDK 设置为 iPhone OS 3.0。将目标设备设置为您的首选目标( iPad、iPhone OS 3.2 在我的情况下。)”
This yields the error "Library not found for -lcrt1.3.1.o"
这会产生错误“未找到 -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.)"
“确保 GCC 没有链接到错误版本的标准库。(你必须确保 LIBRARY_SEARCH_PATH 中没有错误的路径。)”
My LIBRARY_SEARCH_PATH is already empty, so this doesn't seem relevant.
我的 LIBRARY_SEARCH_PATH 已经是空的,所以这似乎无关紧要。
"Try compiling with GCC 4.0 rather than GCC 4.2."
“尝试使用 GCC 4.0 而不是 GCC 4.2 进行编译。”
I get a syntax error inside a UIKit header file. The error is "Syntax error before 'AT_NAME' token." The line is "UIKIT_EXTERN @interface UILocalizedIndexedCollation : NSObject."
我在 UIKit 头文件中收到语法错误。错误是“'AT_NAME' 标记之前的语法错误。” 该行是“UIKIT_EXTERN @interface UILocalizedIndexedCollation : NSObject”。
Another project compiles just fine with the same target settings,which is really making me question my sanity. Could I be dealing with a corrupt XCode project?
另一个项目使用相同的目标设置编译得很好,这真的让我怀疑我的理智。我可以处理损坏的 XCode 项目吗?
If anyone knows what's actually happening and has a reference or doesn't mind explaining it, I would be so very grateful.
如果有人知道实际发生了什么并且有参考或不介意解释它,我将非常感激。
Cheers!
干杯!
采纳答案by Yann Ramin
VFP between ARMv7 and ARMv6 differs in various ways. In ARMv7 its usually preferable to use NEON. The problem is your static library depends on VFP in ARMv6 - you either need to compile the library at ARMv7 or keep the whole application at ARMv6.
ARMv7 和 ARMv6 之间的 VFP 有很多不同之处。在 ARMv7 中,通常最好使用 NEON。问题是您的静态库依赖于 ARMv6 中的 VFP - 您需要在 ARMv7 上编译库或将整个应用程序保持在 ARMv6。
Reverting back to GCC 4.0 is silly - ARMv7 support was basically nonexistent back then unless Apple backported it.
恢复到 GCC 4.0 是愚蠢的 - ARMv7 支持在那时基本上不存在,除非 Apple 向后移植它。
回答by reutiman
I had the same errors except it was for armv6. I fixed them by unchecking "Compile for Thumb" in the project settings for the static library and the main project.
我有同样的错误,除了它是针对 armv6 的。我通过在静态库和主项目的项目设置中取消选中“为 Thumb 编译”来修复它们。
回答by Durai Amuthan.H
As far as AT_NAME error is concerned one of the possiblity is Check if you miss the @end in a class.
就 AT_NAME 错误而言,可能性之一是检查您是否错过了类中的 @end。
To know more about AT_NAME error visit the following link
要了解有关 AT_NAME 错误的更多信息,请访问以下链接
http://iosdevelopertips.com/xcode/error-syntax-error-before-at_name-token.html
http://iosdevelopertips.com/xcode/error-syntax-error-before-at_name-token.html