Page 1 of 1

gcc cross compiler problem

Posted: Mon Jul 03, 2006 1:37 am
by simmy
sorry guys, im not too good at this cross compiler stuff.

ok so i did the first part of the gcc cross compiler tutoral, like the part until you get to troubleshooting and what not.

So i went back to the barebones turorial and i try the as -o loader.o loader.s thing and i get the same unrecognized character.

i dont really understand the usage part of the gcc cross compiler tutorial.

what am i missing???????

notes: i have cygwin with the full package.

thank you!

Re:gcc cross compiler problem

Posted: Mon Jul 03, 2006 2:52 am
by Solar
simmy wrote: So i went back to the barebones turorial and i try the as -o loader.o loader.s thing and i get the same unrecognized character.

i dont really understand the usage part of the gcc cross compiler tutorial.

what am i missing???????
You have to use your cross-compiler tools. ;) If you used /usr/cross as prefix, that means your cross-compiler tools are not in the search path for executables. 'as' is still the same 'as' that came with Cygwin, which doesn't know about ELF format.

The cross-compiler 'as' can be accessed as /usr/cross/bin/${TARGET}-as, or /usr/cross/${TARGET}/bin/as.

I would recommend you add /usr/cross/bin to your executable search path, by editing ~/.bash_profile :

Code: Select all

export PATH=$PATH:/usr/cross/bin
Then, follow the BareBones tutorial using ${TARGET}-as (e.g., i586-elf-as) instead of just 'as'.

Re:gcc cross compiler problem

Posted: Mon Jul 03, 2006 11:04 am
by simmy
so when i followed the tutorial i was suppose to fill in stuff like TARGET, PREFIX, and PATH with my own information i guess?

Re:gcc cross compiler problem

Posted: Tue Jul 04, 2006 12:27 am
by Solar
TARGET is the platform you want to target, e.g. i386-elf, i586-elf or the like.

PREFIX is where you want the stuff to be installed, like /usr/cross (recommended to keep things apart from the system toolchain).

The tutorial starts with the very two lines where you set these (Step 1 - Bootstrap, Preparation)...

Code: Select all

export PREFIX=/usr/cross
export TARGET=i586-elf
Later, prior to making the GCC, you extend the path:

Code: Select all

export PATH=$PATH:$PREFIX/bin
This is verbatim, i.e. you don't have to change anything. In fact, the only thing you have to change at all in the tutorial commands is exchanging [tt]binutils-x.xx[/tt] and [tt]gcc-x.x.x[/tt] with the actual versions you use (e.g., binutils-2.16.1 and gcc-4.0.2 or whatever).

Re:gcc cross compiler problem

Posted: Mon Jul 10, 2006 3:45 pm
by aggieben
I also have been having problems getting a working cross-tool chain.

First, I tried just using the cross-* setup that is now part of OpenBSD. Everything seemed to build fine, but when I went to create binaries, I always ended up with errors like "unresolved symbol __udivsi3" for symbols that *are* in libgcc (I verified with nm) but somehow not linked.

I compile like this:

gcc -c -o kernel.o -g -I../include kernel.c
ld -o kernel.img -lgcc -nostdlib kernel.o

I'm using -nostdlib, which would normally prevent the linking of libgcc, but when you explicitly link libgcc (with -lgcc), the symbols should be found ...but they're not.

I repeated the process by compiling all my cross tools from source (binutils and gcc) to make sure it wasn't just a problem with the OpenBSD cross-tool setup, but I got the same result. I'm building for arm-unknown-elf. I'm trying to build a kernel image to run directly on hardware (ok, ok, a QEMU Arm emulator).

Any help is appreciated.

Re:gcc cross compiler problem

Posted: Tue Jul 11, 2006 12:12 am
by froggey
Because of the way ld handles libraries, you need to put -lgcc last:
ld -o kernel.img -nostdlib kernel.o -lgcc

Re:gcc cross compiler problem

Posted: Thu Jul 20, 2006 10:45 pm
by simmy
ok i get an Error 2 after i install the gcc tools.

during the binutils it says the gcc cross compiling is not working.

same thing during the gcc installation.

is there a way i can get a preconfigured cross compiler?!

i unpacked the .bz2 of both the gcc 4.1.1 and binutils 2.16.1 with 'tar -xjf' and then followed the tutorial.

Re:gcc cross compiler problem

Posted: Fri Jul 21, 2006 1:03 am
by Solar
I'd daresay some previous attempt at building a crosscompiler either screwed up your PATH, or your system compiler installation, or both, so that the binutils build procedure tries to run a non-functional system compiler.

Your best chance is probably to uninstall Cygwin, reinstall it (rather quickly done if you keep the downloaded packages intact), and try the tutorial again. It does work, I re-verified it with binutils-2.17 and GCC 4.1.1 just this morning.

Re:gcc cross compiler problem

Posted: Sat Jul 22, 2006 9:58 pm
by simmy
how do i add /usr/src/cross to my PATH variable?

i can now show you the error i recieved after going to the end of step one of the gcc cross compiling tutorial:

http://216.39.201.3/members/images/error.PNG

Re:gcc cross compiler problem

Posted: Sun Jul 23, 2006 2:14 am
by Solar
export PATH=$PATH:/usr/cross/bin

It's in the tutorial, actually... you might want to add this line to your ~/.profile so it gets executed when you log in...

Oh, and when you report a build error, always report the topmost error, not the last line printed. In your case, the "real" error was:

Code: Select all

make[2]: i586-elf-ar: Command not found

Re:gcc cross compiler problem

Posted: Sun Jul 23, 2006 2:30 am
by simmy
thanks for the advice

any suggestions on how to fix the error...?

Re:gcc cross compiler problem

Posted: Sun Jul 23, 2006 3:19 am
by Solar
By adding /usr/cross/bin to your path?

Re:gcc cross compiler problem

Posted: Sun Jul 23, 2006 10:37 am
by simmy
but i recieved this while i was installing gcc,not when trying to use it..