building an i386 binary on a ppc machine using gcc

This is a discussion on building an i386 binary on a ppc machine using gcc within the C Programming forums, part of the General Programming Boards category; hello all, using gcc 4.0.1 on a Mac OS X 10.4 (i386) i am able to produce successfully a "ppc" ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    22

    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:
    ___keymgr_dwarf2_register_sections
    __cthread_init_routine
    _atexit
    _errno
    _exit
    _mach_init_routine
    _puts
    collect2: ld returned 1 exit status

    Why does this happen ?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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.

    --
    Mats
    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
    Posts
    14
    you need to have a toolchain for architecture, one can be built using buildroot: http://buildroot.uclibc.org/ or scratchbox: http://scratchbox.org/

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, 07:02 PM
  4. Replies: 7
    Last Post: 07-06-2004, 09:16 PM
  5. binary
    By webturtle0 in forum A Brief History of Cprogramming.com
    Replies: 52
    Last Post: 12-05-2002, 01:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21