Adept code for intel and PowerPC?

Discussion in 'Mac Programming' started by trey5498, Aug 6, 2008.

  1. trey5498 macrumors regular

    Joined:
    Jun 16, 2008
    #1
    I have finished my installer and it works perfectly on the Intel Mac (OS X 10.4 and 10.5) however there is a good number of people that wish to use my code on the PowerPC, I know the compiled code will not work on the PowerPC since it was compiled on the Intel. How do I convert it so that it will or make it universal?
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Are you compiling with Xcode or the command line?
     
  3. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #3
    I am compiling it in Xcode by using the build button, is there a setting that will help with this?
     
  4. gnasher729 macrumors P6

    gnasher729

    Joined:
    Nov 25, 2005
    #4
    In "Targets", click on the target for the shipping application, "Get Info". Choose the "Release" configuration (you probably don't want PowerPC for debugging), then under "Architectures" enter "ppc i386".

    For testing you _should_ have a PowerPC Mac. If you don't, change "Architectures" to "ppc" only. This will build only ppc code which will then run under Rosetta. This should find most bugs. The biggest compatibility problem is usually using fread and fwrite to read or write structs to a file - PowerPC and x86 have different byte ordering, so this will create files that are not compatible. Obviously you'll want to switch back to "ppc i386" once you're done testing.
     
  5. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #5
    I have changed the top part to ppc it had already said i386 ppc. When I compiled it and then tried it on a ppc 10.4 it did not work. Didnt even show up on the screen with an error anything. It is a cocoa program and uses popen and pclose. Did I miss something?
     
  6. sord macrumors 6502

    Joined:
    Jun 16, 2004
    #6
    Did you build a Debug version or a Release version?

    An app built as debug won't work on another machine.
     
  7. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
  8. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #8
    Update. I have tried everything that I can think of to compile it as PPC. It is an intel mac OS X 10.5 and Xcode 3.0. I dont want to redo the code all over again from scratch. How do I get this thing complete?
     
  9. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #9
    Have you checked the console when you try to run it on a PPC machine to see if there are any messages being printed there?

    If the program is actually crashing, invoking it from the command-line with GDB instead of clicking the app bundle might tell you where it's dying.

    What version(s) of OS X are on the PPC machines you are testing? Are they also 10.4 or 10.5?

    -Lee
     
  10. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #10
    Are you building with the correct SDK version for the Mac OS X version running on the PPC machine? If you are compiling against the 10.5 SDK it won't work at all if the PPC machine is running 10.4.

    Plus don't forget things like garbage collection are not available if you are using Tiger.
     
  11. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #11
    If I compile it as 10.4 will it work on 10.5, 10.4, and 10.3? And do I need to bump it down from Xcode 3.0 to 2.4?
     
  12. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #12
    Ok at least I am getting somewhere. I had to change a few things in the code to get the version checker working as 10.4 doesn't seem to have the NSAppKitVersionNumber10_4 so I changed it to 10_3 how I have another error I can't even find on the net.

    it is a error on linking the project and it gives me the following error msg:

    "_objec_enumeration", referenced from:

    How do I solve that?
     
  13. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #13
    Are you using Objective-C 2.0? If so Mac OS X 10.4 only supports Objective-C 1.0, remove everything like fast enumeration and the like to get it to work.
     
  14. trey5498 thread starter macrumors regular

    Joined:
    Jun 16, 2008
    #14
    so I would have to set all the value Hardcoded in instead of having like

    Array = {a, b, c, d};

    Where Array is a NSMutableArray and a throu d are objects, of course the array is properly allocated in the code, I just threw something here to have an understanding.
     
  15. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #15
    Nah, if you wrote your code to use the new Objective-C features found in Leopard, it will most likely be incompatible with Tiger. Make sure you are using the old style if you want your programs to work. I'm not great at Objective-C so can't give you any hard and fast examples unfortunately.
     

Share This Page