Page 1 of 1

Just compiled the cross-compiler, but having problems...

Posted: Wed May 06, 2009 6:52 pm
by Auraomega
Hi,

Sorry to be a nuisance on my first post! I've just finally compiled my cross compiler after numerous problems, and my sleep deprived brain cannot work out whats going wrong with the examples on the Wiki, I'm worried that theres been an error with my cross compiler.

I've basically just done copy and paste on the examples (don't look at me like that >.>) and attempted to get it all up and running. I assembled the stub without issue, but when it came to the kernel.o I was getting these errors:
kernel.c: In function `kmain':
kernel.c:14: warning: unused variable `boot_loader_name'
First off I removed the flags which allows it to compile, but it didn't work so I compiled again with flags on but removed the problematic lines. In both cases when it came to linking the files I get this error:
loader.o: In function `loader':
C:\cygwin\home\Auraomega\OS\loader.s:(.text+0x14): undefined reference to `kmain'
I'm using Cygwin (was on Windoze when I found this site), NASM, and GCC version 4.4.0. When compiling GCC it did give me an error in which it couldn't find a certain function to do with mpfr, those lines (1150) didn't appear to do anything except check that the version was correct (but again, I'm nackered so I might have overlooked something) so I commented them out and the compiling went fine after that.

I'm hoping its something glaringly obvious and that I'm just to tired to notice it, better that than have to re-compile the cross compiler again. So, any help/advice would be really appreciated.

-Aura

P.S. sorry if this has been asked/answered in the past, I couldn't think of how to word "compiler error" and get something helpful.

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 12:18 am
by Combuster
C:\cygwin\home\Auraomega\OS\loader.s:(.text+0x14): undefined reference to `kmain'
are you actually using the crosscompiler? This looks like cygwin's version of GCC.

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 3:40 am
by AJ
Agree - can we see your command line? Also, could you post the output of:

Code: Select all

i586-elf-gcc --v
What if you leave your warning flags in place, but just comment out the declaration of boot_loader_name?

Cheers,
Adam

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 4:09 am
by Auraomega
bash: i586-elf-gcc: command not found
, I'm assuming either my PATH is incorrectly set, or that my compiler isn't setup right? To set up my path I use

Code: Select all

export PREFIX=/usr/cross && export TARGET=i586-elf && export PATH=$PATH:$PREFIX/bin
, I've even tried using $TARGET-gcc per the Wiki but I get the same issues.

When I comment out boot_loader_name it gives me an unused variable warning for mbd which means I have to remove that also leaving me with

Code: Select all

void kmain(unsigned int magic)
as this was the only method under which it would compile with flags set.

-Aura

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 4:31 am
by AJ
Hi,

Sorry if this seems patronising, but you did build the install-gcc target in addition to the all-gcc target, didn't you? If so, something went wrong with the GCC configure / build and you need to follow the cross-compiler tutorial again.

Cheers,
Adam

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 7:52 am
by sebihepp
Hello,

first of all: don't give up. I had to spend much time (and many nerves) to building my gcc crosscompiler. :wink:
You can use your crosscompiler with i586-elf-*, where * is one of gcc, ld, etc.

The rest I want to say had been mentioned one post above. :)

Greetings
Sebihepp

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 2:11 pm
by Auraomega
Thanks guys, I decided to try configure make all-gcc make install-gcc again, and it worked flawlessly. I've since managed to compile the example kernel, and link it all together.

However, I'm still having a problem, as Solar mentioned the Bochs section is a bit... bad. I've attempted using kernel 200+6 (my kernel size), but this wouldn't work so I attempted to work out what the 200 was for, I'm assuming (via the comment by Solar) its the stage1 and stage2 size, which for me totals 199. So I'm begining to believe that the 200 is something else (kernel 199+6 fails too)?

Anyway, once this is out of the way I'll be able to get on with things, although I'm more and more swaying towards using ASM for my project as I have a (very) basic kernel already coded in ASM.

-Aura

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 3:06 pm
by Love4Boobies
Your previous post really doesn't make much sense. I'm not really familiar to GRUB so I had no idea what you were mumbling about with the "using kernel 200+6 (my kernel size)" until I took a glance at the Bare Bones tutorial which I'm assuming you used. 200 is the block (LBA) where the kernel is supposed to be on your image. You forgot to mention in what way it doesn't work. Maybe you didn't correctly build your image?

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 4:35 pm
by Auraomega
Sorry. The error is
Error 13: Invalid or unsupported executable format
I created the image per the Wiki

Code: Select all

cat stage1 stage2 pad kernel.bin pad2 > floppy.img
with pad being 750 bytes big, and pad2 bringing to total to 1,474,560 bytes.

My kernel.bin is 2,845 bytes long. 2,845 / 512 = 5.55... = 6 blocks.

-Aura

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 6:23 pm
by Love4Boobies
Ah. You should have mentioned the error. Are you using a cross-compiler or...?

Re: Just compiled the cross-compiler, but having problems...

Posted: Thu May 07, 2009 8:14 pm
by Auraomega
Yep... all details are in the rest of this thread.

-Aura

Re: Just compiled the cross-compiler, but having problems...

Posted: Fri May 08, 2009 2:42 am
by Love4Boobies
The details in this thread aren't enough. What targets did you use? Did you also build cross-binutils? If you're targeting PE, GRUB won't be able to load your kernel, regardless of your Multiboot header. Also, you might have built your toolchain but still be using the old one - that's a common problem with Cygwin users on this forum.

Re: Just compiled the cross-compiler, but having problems...

Posted: Fri May 08, 2009 7:24 am
by Auraomega
I've sorted it, I didn't realise the linker needed to be specific too, using $TARGET-ld worked #-o

-Aura