Xcode 4 links wrong version in orx-iphone

For the fast few weeks I've been working with Orx SVN and Xcode 4.2.1 to develop for iOS. This is my first experience with iOS dev and Xcode, so please excuse any newbie mistakes.

For testing the Debug version of my project on the device, everything seemed to work pretty well in the sample project from SVN.

When I changed to the Release version, though, things didn't work quite right. Basically I noticed some strange behavior in the simulator and on the device. Objects wouldn't delete properly and there would be crashes.

It seems the release version of the orxTest target was still linking the debug version of orxLIB and this was causing the problem.

The orxTest target has this option set by default: Summary | Linked Frameworks and Libraries | liborxd.a | Required

I set this option to make sure it links the correct version of orxLIB for the Release version: Build Settings | Linking | Other Linker Flags | Release | Any Architecture | Any SDK | <path-to-orx-source>/orx/code/lib/static/iphone/liborx.a

After making that change, the Release version seems to correctly link the release version of orxLIB and the strange behavior disappeared.

Comments

  • edited January 2012
    Mmh, interesting.
    I don't have XCode 4 at home so, if you don't mind, you could send me the project file, I'll put it on the SVN.
    I guess the conversion from the XCode3 format doesn't work that well.
  • edited January 2012
    No problem B) The modified Xcode project is attached. Here's what I did to make it work correctly.

    - Retrieve orx-iphone.xcodeproj from SVN
    - Remove this:

    Targets | orxTest | Summary | Linked Frameworks and Libraries | orxlibd.a

    - Add these options:

    Build Settings | Linking | Other Linker Flags | Debug | Any Architecture | Any SDK | ../../../lib/static/iphone/liborxd.a

    Build Settings | Linking | Other Linker Flags | Profile | Any Architecture | Any SDK | ../../../lib/static/iphone/liborxp.a

    Build Settings | Linking | Other Linker Flags | Release | Any Architecture | Any SDK | ../../../lib/static/iphone/liborx.a

    Tested Debug and Release in both iPhone Simulator and my iPod Touch and no more freezing. The Release version of the orxTest freezes and crashes in Simulator and on device without these changes.

    Note: I did not change the Xcode compatibility level, so I think the project I attached should also still work in Xcode 3, but I can't test that. https://forum.orx-project.org/uploads/legacy/fbfiles/files/orx_iphone.zip
  • edited January 2012
    Thanks!

    I'll try that during the week, whenever I get the opportunity. :)
  • edited January 2012
    So I tried to replace my XCode project with yours (many times actually) but as soon as I open it with XCode3, all the diffs disappear and it end up being exactly the same as before. :(
  • edited January 2012
    Crap. I think Xcode is a bit buggy with the different file formats. I get strange crashes in Xcode 4 sometimes.

    I guess you could make the changes I described to the Xcode 3 project. Here is a link describing how to find the "Other Linker Flags" in Xcode 3:

    http://developer.adfonic.com/index.php/IOS_SDK

    Let me know if I can help in any other way.
  • edited January 2012
    Did you get it sorted out?

    If not, let me know the exact version of Xcode you're using and I'll try to send you another one that hopefully works...
  • edited January 2012
    Guys, why some of you are still using Xcode 3? Isn't it old and dead yet? Just curious :)

    Thanks,
    Alex
  • edited January 2012
    @acksys: I haven't had the time yet, sorry. Working late on evenings -> falling asleep when getting home. :)

    @godexsoft: There's nothing I hate more than XCode 3 except XCode 4. I'll get over it and will install it. Eventually. :)
  • edited January 2012
    So, I'm currently updating the XCode project files to account for the new orxFX/orxFXPointer location (that moved from render to object, which makes much more sense now).

    I'll also update the project file to link against orx using explicitly defined command line parameters (which I'm using in my game projects as it's the only way to go when using a pre-compiled library, afaik).

    Everything should be on svn within 10 mins. Let me know if it worked for XCode 4. :)
  • edited January 2012
    Almost there! But because you still have orxTest | Summary | Linked Frameworks and Libraries | liborxd.a defined, orxTest attempts to link both debug and release libraries:
    Ld build-iphone/orxTest.app/orxTest normal i386
        cd /Users/oris/Documents/orx/code/build/mac/xcode
        setenv MACOSX_DEPLOYMENT_TARGET 10.6
        setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
        /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang++ -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/oris/Documents/orx/code/build/mac/xcode/build-iphone -L../../../lib/static/iphone -F/Users/oris/Documents/orx/code/build/mac/xcode/build-iphone -filelist /Users/oris/Documents/orx/code/build/mac/xcode/build-iphone/orx-iphone.build/Release-iphonesimulator/orxTest.build/Objects-normal/i386/orxTest.LinkFileList -mmacosx-version-min=10.6 -no_dead_strip_inits_and_terms -Xlinker -objc_abi_version -Xlinker 2 -lorx -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=30100 -lorxd -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -o /Users/oris/Documents/orx/code/build/mac/xcode/build-iphone/orxTest.app/orxTest
    
    ld: library not found for -lorxd
    Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang++ failed with exit code 1
    

    So build of orxTest fails if the liborxd hasn't been built yet... if it has, the build would link with both debug and release, which is probably not what we want.

    But if you remove that reference, it works unconditionally here.
  • edited January 2012
    I was afraid of that. I removed the reference for the mac projects but I had to put it back for the iPhone project.

    The reason is that on the mac project there's a 'All' target that will reference orxLib and make sure it's compiled before the other targets. I couldn't find a way to create the 'All' target for iPhone. :(

    Unless you know how to create such a target, a solution would then be to create two projects, one for actually compiling orx for my needs and one other that would be for the test project and that would link against the compiled library instead of compiling orx all the time. Not ideal but if you have another idea, let me know!
  • edited January 2012
    Hmm, I don't know how Xcode 3 works, but Xcode 4 implicitly knows orxLIB is required to build orxTest, so it builds orxLIB first if it's not already there.

    See this screenshot for the "scheme" where this is illustrated: http://imgur.com/LkPFd

    The one exception to this I've found is when changing architectures. For example, if I've built and tested the project on iPhone Simulator, I have to explicitly rebuild orxLIB before I can build the project for a real iOS device. Otherwise, Xcode sees the iPhone Simulator orxLIB already exists, tries to link to it, and fails.
  • edited January 2012
    Well that's the thing. This doesn't exist in XCode 3, at least not like that.

    And XCode 4 converts incorrectly the project file if I set the dependency in XCode 3 using the target sub-tree and it ends up in linking against the wrong version. I'll try to find more info about that next week end.
Sign In or Register to comment.