Discussion:
Cross compiling with the i386-elf toolchain?
David Smoot
2006-10-04 13:43:12 UTC
Permalink
I'm trying to learn cross compiling out of curiousity for an idea I'm
playing with at work.

I have a powerbook G4 (ppc) with the i386-elf port for GCC and binutils
installed. I'm trying to compile a simple "hello world" application that
just has a single printf.

In a terminal I type:
i386-elf-gcc-3.4.3 -c main.c
and I get the expected main.o

now I type
i386-elf-gcc-3.4.3 -o hello main.o
and I get:
/opt/local/lib/gcc/i386-elf/3.4.3/../../../../i386-elf/bin/ld: crt0.o: No
such file: No such file or directory

So my problem is linking. I've exhausted my google abilities and
knowledge. I think I need something like:
i386-elf-gcc-3.4.3 -o hello main.o -I/opt/local/i386-elf/include -Wl,
-nostdlib but so far I cannot figure it out.

If someone will help me figure out a simple "hello world" cross compile
recipe for these tools I would be most appreciative.

Thanks
David
Paul Guyot
2006-10-04 15:15:25 UTC
Permalink
Cross toolchains such as MacPort's i386-elf are target agnostic. They
rely on a minimum runtime glue code (in crt0.o file). This library
highly depends on the kind of target you are targetting. You can
either compile/write one yourself in assembly language (that's the
approach for targets with open-source crt0 file) or use one from the
SDK of the platform you are targetting.

HTH,

Paul
Post by David Smoot
I'm trying to learn cross compiling out of curiousity for an idea I'm
playing with at work.
I have a powerbook G4 (ppc) with the i386-elf port for GCC and
binutils
installed. I'm trying to compile a simple "hello world"
application that
just has a single printf.
i386-elf-gcc-3.4.3 -c main.c
and I get the expected main.o
now I type
i386-elf-gcc-3.4.3 -o hello main.o
crt0.o: No
such file: No such file or directory
So my problem is linking. I've exhausted my google abilities and
i386-elf-gcc-3.4.3 -o hello main.o -I/opt/local/i386-elf/include -Wl,
-nostdlib but so far I cannot figure it out.
If someone will help me figure out a simple "hello world" cross compile
recipe for these tools I would be most appreciative.
Thanks
David
_______________________________________________
macports-users mailing list
http://lists.macosforge.org/mailman/listinfo/macports-users
--
Ministre ultraplénipotentiaire en disponibilité.
Mobile. Sans baignoire fixe.
http://www.kallisys.com/
http://www-poleia.lip6.fr/~guyot/
Loading...