Thread: building an i386 binary on a ppc machine using gcc

  1. #1
    Registered User
    Join Date
    Aug 2008

    building an i386 binary on a ppc machine using gcc

    hello all,
    using gcc 4.0.1 on a Mac OS X 10.4 (i386) i am able to produce successfully a "ppc" binary
    # gcc -arch ppc -o prg prg.c

    But I am not able to produce an i386 binary on a "ppc" machine
    # gcc -arch i386 -o prg prg.c

    /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning fat file: /usr/lib/gcc/i68 6-apple-darwin8/4.0.1/../../../libSystem.dylib does not contain an architecture that matches the specified -arch flag: i386 (file ignored)
    /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
    collect2: ld returned 1 exit status

    Why does this happen ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    You'll need to build your own gcc that is "cross target" meaning that the compiler is built to run on PPC, and to compile for i386. You will also need to build binutils for cross building and build the C library with the cross-compiler - and of course any other libraries that you need.

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User bboozzoo's Avatar
    Join Date
    Jan 2009
    you need to have a toolchain for architecture, one can be built using buildroot: or scratchbox:

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 10-09-2006, 09:08 AM
  2. Confused by expression.
    By Hulag in forum C Programming
    Replies: 3
    Last Post: 04-07-2005, 07:52 AM
  3. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 08:02 PM
  4. Replies: 7
    Last Post: 07-06-2004, 09:16 PM
  5. binary
    By webturtle0 in forum A Brief History of
    Replies: 52
    Last Post: 12-05-2002, 02:46 AM