Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode linking error when targeting armv7

I've already spent countless hours puzzling over this, utilizing Google searches and other Stack Overflow questions to no avail.

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:

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:

  "___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.)"

This yields the error "Library not found for -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.)"

My LIBRARY_SEARCH_PATH is already empty, so this doesn't seem relevant.

"Try compiling with GCC 4.0 rather than 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."

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?

If anyone knows what's actually happening and has a reference or doesn't mind explaining it, I would be so very grateful.

Cheers!

like image 515
Tom Avatar asked May 10 '10 17:05

Tom


2 Answers

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.

Reverting back to GCC 4.0 is silly - ARMv7 support was basically nonexistent back then unless Apple backported it.

like image 152
Yann Ramin Avatar answered Sep 28 '22 04:09

Yann Ramin


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.

like image 35
reutiman Avatar answered Sep 28 '22 05:09

reutiman