I'm having some problems with my iPhone app not linking for the iPhone Simulator. It tells me there are undefined symbols:
Undefined symbols for architecture i386:
".objc_class_name_NSRunLoop", referenced from:
pointer-to-literal-objc-class-name in SampleBrowser.cpp.o
".objc_class_name_NSDate", referenced from:
pointer-to-literal-objc-class-name in SampleBrowser.cpp.o
".objc_class_name_NSAutoreleasePool", referenced from:
pointer-to-literal-objc-class-name in SampleBrowser.cpp.o
pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
".objc_class_name_UIApplication", referenced from:
pointer-to-literal-objc-class-name in SampleBrowser.cpp.o
pointer-to-literal-objc-class-name in libOIS.a(iPhoneInputManager.mm.o)
".objc_class_name_NSObject", referenced from:
.objc_class_name_AppDelegate in SampleBrowser.cpp.o
".objc_class_name_UIView", referenced from:
.objc_class_name_SampleBrowserGestureView in SampleBrowser.cpp.o
.objc_class_name_InputDelegate in libOIS.a(iPhoneInputManager.mm.o)
.objc_class_name_EAGL2View in libRenderSystem_GLES2Static.a(OgreEAGL2View.mm.o)
".objc_class_name_UIScreen", referenced from:
pointer-to-literal-objc-class-name in libOIS.a(iPhoneInputManager.mm.o)
pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Support.mm.o)
".objc_class_name_UIAccelerometer", referenced from:
pointer-to-literal-objc-class-name in libOIS.a(iPhoneInputManager.mm.o)
pointer-to-literal-objc-class-name in libOIS.a(iPhoneAccelerometer.mm.o)
But these looks like the names of Objective-C classes from frameworks which I AM linking against. I wanted to do some digging around so I used nm to look at the symbol list of the frameworks I'm linking against. For instance
josh$ nm /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Foundation -arch i386 -g | grep objc_class
001a4500 S $ld$add$os10.4$.objc_class_name_NSArray
001a4501 S $ld$add$os10.4$.objc_class_name_NSCalendar
001a4502 S $ld$add$os10.4$.objc_class_name_NSData
001a4503 S $ld$add$os10.4$.objc_class_name_NSDate
001a4504 S $ld$add$os10.4$.objc_class_name_NSDateComponents
001a4505 S $ld$add$os10.4$.objc_class_name_NSDictionary
001a4506 S $ld$add$os10.4$.objc_class_name_NSEnumerator
001a4507 S $ld$add$os10.4$.objc_class_name_NSException
001a4508 S $ld$add$os10.4$.objc_class_name_NSInputStream
001a4509 S $ld$add$os10.4$.objc_class_name_NSInvocation
001a450a S $ld$add$os10.4$.objc_class_name_NSLocale
001a450b S $ld$add$os10.4$.objc_class_name_NSMethodSignature
001a450c S $ld$add$os10.4$.objc_class_name_NSMutableArray
001a450d S $ld$add$os10.4$.objc_class_name_NSMutableData
001a450e S $ld$add$os10.4$.objc_class_name_NSMutableDictionary
001a450f S $ld$add$os10.4$.objc_class_name_NSMutableSet
001a4510 S $ld$add$os10.4$.objc_class_name_NSNull
001a4511 S $ld$add$os10.4$.objc_class_name_NSObject
001a4512 S $ld$add$os10.4$.objc_class_name_NSOutputStream
001a4513 S $ld$add$os10.4$.objc_class_name_NSRunLoop
001a4514 S $ld$add$os10.4$.objc_class_name_NSSet
001a4515 S $ld$add$os10.4$.objc_class_name_NSStream
001a4516 S $ld$add$os10.4$.objc_class_name_NSTimeZone
001a4517 S $ld$add$os10.4$.objc_class_name_NSTimer
001a4548 S $ld$add$os10.4$.objc_class_name_NSURL
001a4518 S $ld$add$os10.4$.objc_class_name_NSUserDefaults
001a4549 S $ld$add$os10.5$.objc_class_name_NSURL
001a454a S $ld$hide$os10.4$.objc_class_name_NSFileWrapper
001a454b S $ld$hide$os10.5$.objc_class_name_NSFileWrapper
001a454c S $ld$hide$os10.6$.objc_class_name_NSFileWrapper
Now, this symbol list makes it look to me like that framework archive IS exporting the classes that the linker is looking for. The only thing that's different is this $ld$add$os10.4$ prefix. I'm wondering why it's there, what it means, and is that, perhaps, causing my problem?
Edit: Looks like this was my problem: Link errors in Xcode when targeting iPhoneSimulator
In short, leaving off the compiler flag -fobjc-abi-version=2 leads to the different symbol naming.