linker problems building unstable ogre for iOS simulator

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
cheshirekow
Gnoblar
Posts: 21
Joined: Thu Dec 16, 2010 5:13 pm

linker problems building unstable ogre for iOS simulator

Post by cheshirekow »

I believe that I've managed to build ogre from the mercurial repository for iOS using the latest SDK (5.1 on osx 10.7). It at least builds the samples and sample browser without a problem (haven't tried it on actual hardware yet, will report back in about a week when we get an iPad to develop on).

My problem is that I can't seem to get it to link the sample browser for the simulator. Here's the output of from the console:

Code: Select all

Linking CXX executable ../../bin/SampleBrowser.app/Contents/MacOS/SampleBrowser
cd /Users/josh/Documents/dev/ogre_src/hg_build/i686/Samples/Browser && "/Applications/CMake 2.8-7.app/Contents/bin/cmake" -E cmake_link_script CMakeFiles/SampleBrowser.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2   -g -O0 -Wall -arch i686 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -D__IPHONE_OS_VERSION_MIN_REQUIRED=40000 -mmacosx-version-min=10.7 -g -DDEBUG -arch i686 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -framework Foundation -framework CoreGraphics -framework QuartzCore -framework UIKit CMakeFiles/SampleBrowser.dir/src/SampleBrowser.cpp.o CMakeFiles/SampleBrowser.dir/src/FileSystemLayerImpl_iOS.mm.o  -o ../../bin/SampleBrowser.app/Contents/MacOS/SampleBrowser  -L/Users/josh/dev/root/iPhoneSimulator/usr/lib ../../lib/libOgreMainStatic.a ../../lib/libPlugin_OctreeSceneManagerStatic.a ../../lib/libPlugin_BSPSceneManagerStatic.a ../../lib/libPlugin_ParticleFXStatic.a ../../lib/libPlugin_PCZSceneManagerStatic.a ../../lib/libPlugin_OctreeZoneStatic.a ../../lib/libOgreRTShaderSystemStatic.a ../../lib/libOgreTerrainStatic.a ../../lib/libRenderSystem_GLESStatic.a ../../lib/libRenderSystem_GLES2Static.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libOIS.a ../../lib/libSample_BezierPatch.a ../../lib/libSample_CameraTrack.a ../../lib/libSample_Character.a ../../lib/libSample_Compositor.a ../../lib/libSample_DualQuaternion.a ../../lib/libSample_DynTex.a ../../lib/libSample_FacialAnimation.a ../../lib/libSample_Grass.a ../../lib/libSample_Instancing.a ../../lib/libSample_Lighting.a ../../lib/libSample_NewInstancing.a ../../lib/libSample_Ocean.a ../../lib/libSample_ParticleFX.a ../../lib/libSample_ShaderSystem.a ../../lib/libSample_ShaderSystemMultiLight.a ../../lib/libSample_Shadows.a ../../lib/libSample_SkeletalAnimation.a ../../lib/libSample_SkyBox.a ../../lib/libSample_SkyDome.a ../../lib/libSample_SkyPlane.a ../../lib/libSample_Smoke.a ../../lib/libSample_SphereMapping.a ../../lib/libSample_Terrain.a ../../lib/libSample_TextureFX.a ../../lib/libSample_TextureArray.a ../../lib/libSample_Transparency.a ../../lib/libSample_VolumeTex.a ../../lib/libSample_Water.a ../../lib/libSample_BSP.a ../../lib/libSample_CelShading.a ../../lib/libSample_DeferredShading.a ../../lib/libSample_CubeMapping.a ../../lib/libSample_Dot3Bump.a ../../lib/libSample_Fresnel.a ../../lib/libSample_Isosurf.a ../../lib/libSample_ParticleGS.a ../../lib/libSample_SSAO.a ../../lib/libPlugin_OctreeSceneManagerStatic.a ../../lib/libPlugin_BSPSceneManagerStatic.a ../../lib/libPlugin_ParticleFXStatic.a ../../lib/libPlugin_OctreeZoneStatic.a ../../lib/libPlugin_PCZSceneManagerStatic.a ../../lib/libOgreRTShaderSystemStatic.a ../../lib/libOgreTerrainStatic.a ../../lib/libOgrePagingStatic.a ../../lib/libRenderSystem_GLESStatic.a -framework OpenGLES ../../lib/libRenderSystem_GLES2Static.a ../../lib/libOgreMainStatic.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libfreetype.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libfreeimage.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libzzip.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libz.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libboost_thread.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libboost_date_time.a /Users/josh/dev/root/iPhoneSimulator/usr/lib/libOIS.a 
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)
  ".objc_class_name_NSBundle", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Support.mm.o)
  ".objc_class_name_EAGLContext", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGLES2Context.mm.o)
  ".objc_class_name_NSNumber", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
  ".objc_class_name_NSDictionary", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
  ".objc_class_name_CAEAGLLayer", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2View.mm.o)
  ".objc_class_name_UIWindow", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
  ".objc_class_name_UIDevice", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2Window.mm.o)
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2View.mm.o)
  ".objc_class_name_UIViewController", referenced from:
      .objc_class_name_EAGL2ViewController in libRenderSystem_GLES2Static.a(OgreEAGL2ViewController.mm.o)
  ".objc_class_name_NSString", referenced from:
      pointer-to-literal-objc-class-name in libRenderSystem_GLES2Static.a(OgreEAGL2View.mm.o)
ld: symbol(s) not found for architecture i386
From the apple docs, it looks like these undefined symbols should be in the UIKIt and Foundation frameworks. But the link command is linking against those frameworks. Anyone know what the problem could be?
cheshirekow
Gnoblar
Posts: 21
Joined: Thu Dec 16, 2010 5:13 pm

Re: linker problems building unstable ogre for iOS simulator

Post by cheshirekow »

I'm not really compitent enough to understand this but:

Code: Select all

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 NSRunLoop
001a4513 S $ld$add$os10.4$.objc_class_name_NSRunLoop
001a4535 S $ld$add$os10.4$_NSRunLoopCommonModes
         U _NSRunLoopCommonModes
         U _OBJC_CLASS_$_NSRunLoop
         U _OBJC_IVAR_$_NSRunLoop._dperf
         U _OBJC_IVAR_$_NSRunLoop._info
         U _OBJC_IVAR_$_NSRunLoop._perft
         U _OBJC_IVAR_$_NSRunLoop._ports
         U _OBJC_IVAR_$_NSRunLoop._rl
It *looks like* there IS a symbol ".objc_class_name_NSRunLoop" in Foundation.Framework/Foundation. So why can't the linker find it?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: linker problems building unstable ogre for iOS simulator

Post by masterfalcon »

That is quite strange. The first thing that I would check is that all the steps in the first section on this wiki page have been followed, you may need to delete your build folder and reconfigure if anything is changed. http://www.ogre3d.org/tikiwiki/tiki-ind ... %20iPhone)

Second, if you're using Xcode 4.3, you'll need to get the CMake 2.8.8 release candidate for proper support. http://www.cmake.org/files/v2.8/
cheshirekow
Gnoblar
Posts: 21
Joined: Thu Dec 16, 2010 5:13 pm

Re: linker problems building unstable ogre for iOS simulator

Post by cheshirekow »

Thanks for the reply.

If you mean the steps on setting up XCode, I followed all of them except for updating CMake. Instead, I'm using the Unix Makefiles output of cmake to build ogre. If you mean the steps on dependencies, I have built all the required dependencies from source, using the same compiler as I'm using to build ogre (llvm-gcc-4.2) .

Please note that all the examples built correctly for the iPhone device (i.e. -arch armv7 and -isysroot pointing to the iOS 5.1 sdk), and it is only building for the iPhone simulator (i.e. -arch i386 -isysroot pointing to the iOSSimulator 5.1 sdk) where this error arises.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: linker problems building unstable ogre for iOS simulator

Post by masterfalcon »

Using makefiles to build Ogre for iOS is unsupported and thus never tested so you may run into issues.
cheshirekow
Gnoblar
Posts: 21
Joined: Thu Dec 16, 2010 5:13 pm

Re: linker problems building unstable ogre for iOS simulator

Post by cheshirekow »

masterfalcon wrote:so you may run into issues.
Clearly ;).

But hopefully I can work around those issues. I did a lot of tracing on the makefiles and the compile and link commands look fine. It's using all the right tools and linking to the right frameworks. The weird thing is that it links fine for the device, just not the simulator.
cheshirekow
Gnoblar
Posts: 21
Joined: Thu Dec 16, 2010 5:13 pm

Re: linker problems building unstable ogre for iOS simulator

Post by cheshirekow »

It turns out there are two extra compiler options that are required when compiling sources for the iOS simulator:

Code: Select all

-fobjc-abi-version=2 
    Use version n of the Objective-C ABI for the selected runtime. This option is currently supported 
    only for the NeXT runtime. In that case, Version 0 is the traditional (32-bit) ABI without 
    support for properties and other Objective-C 2.0 additions. Version 1 is the traditional (32-bit) 
    ABI with support for properties and other Objective-C 2.0 additions. Version 2 is the modern 
    (64-bit) ABI. If nothing is specified, the default is Version 0 on 32-bit target machines, and 
    Version 2 on 64-bit target machines. 

-fobjc-legacy-dispatch 
    Use Objective-C v1 message dispatching