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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post 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.
Windows: Just another pane in the glass.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

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

Post 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
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post 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
Windows: Just another pane in the glass.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

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

Post 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
sebihepp
Member
Member
Posts: 195
Joined: Tue Aug 26, 2008 11:24 am
GitHub: https://github.com/sebihepp

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

Post 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
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post 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
Windows: Just another pane in the glass.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

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

Post 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?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post 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
Windows: Just another pane in the glass.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

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

Post by Love4Boobies »

Ah. You should have mentioned the error. Are you using a cross-compiler or...?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post by Auraomega »

Yep... all details are in the rest of this thread.

-Aura
Windows: Just another pane in the glass.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

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

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Auraomega
Posts: 13
Joined: Wed May 06, 2009 6:20 pm

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

Post by Auraomega »

I've sorted it, I didn't realise the linker needed to be specific too, using $TARGET-ld worked #-o

-Aura
Windows: Just another pane in the glass.
Post Reply