-arch

Discussion in 'Mac Programming' started by rabidz7, Dec 5, 2012.

  1. macrumors 65816

    rabidz7

    #1
    How do i choose the architecture I compile an app for? e.g. ppc, ppc64, i386, i386_64
     
  2. macrumors 6502a

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    In XCode, I assume, right? Under Project Target Settings.
     
  3. thread starter macrumors 65816

    rabidz7

    #3
    Command line tool

    How would I do this in the command line compiler.
     
  4. macrumors member

    Joined:
    Aug 26, 2012
    Location:
    Auckland, New Zealand
    #4
    gcc -arch i386 program.c

    for example
     
  5. thread starter macrumors 65816

    rabidz7

    #5
    Explain

    So, do I do this when i type ./configure or make?
     
  6. macrumors member

    Joined:
    Aug 26, 2012
    Location:
    Auckland, New Zealand
    #6
    Hmmm it's a bit difficult to say without knowing exactly what you are doing.

    it might pay to do some background reading on gcc, option flags, makefiles, etc. but essentially -arch is an option for gcc, which is what compiles your source code.

    You need to add -arch (and your chosen architecture) to the relevant gcc calls. Without knowing your setup this is probably in the configure file or possibly directly in the makefile (although I'm guessing the way you have things setup configure is building your makefile). Anyway, I'd suggest doing background reading on whatever your workflow is so that you understand each step of what is happening :)

    Cheers

    ----------

    Starting with something like this could be useful :)

    http://www.eupcs.org/wiki/Introduction_To_Makefiles
     
  7. thread starter macrumors 65816

    rabidz7

    #7
    clarification


    A am compiling an app from source code on my macbook pro 2011. I first type ./configure then I type make.
     
  8. macrumors member

    Joined:
    Aug 26, 2012
    Location:
    Auckland, New Zealand
    #8
    Yep - so you need to edit your makefile to contain the arch option when GCC is called.

    I really, really recommend reading up on makefiles etc. so you understand what's going on :)

    Good luck!
     
  9. macrumors 6502a

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #9
    Usually you'd say something like

    Code:
    ./configure --help
    It will tell you the options available. It might be something like:

    Code:
    ./configure --with-cflags="-march=i386"
    or something like that. Every package is different.
     
  10. macrumors 6502

    Madd the Sane

    Joined:
    Nov 8, 2010
    Location:
    Utah
    #10
    One way to do it is with
    Code:
    ./configure --with-cflags="-arch i386" --with-ldflags="-arch i386"
    or with
    Code:
    CC="gcc -arch i386" ./configure 
    The arch flag is specific to Darwin/OS X/NeXTStep and won't work on other OSes.
     

Share This Page