Page 1 of 1

undefined reference to 'kmain' ?

Posted: Fri Nov 28, 2008 7:53 am
by quanganht
I've done like this
http://wiki.osdev.org/Bare_bones

And it keep popping to my face like this
Image

Re: undefined reference to 'kmain' ?

Posted: Fri Nov 28, 2008 11:08 am
by piranha
Did you name the function kmain?

I just tested it out here, works perfectly. Did you copy the code exactly?
edit: Damn, duh, that makes sense JamesM. Waste of a post...
-JL

Re: undefined reference to 'kmain' ?

Posted: Fri Nov 28, 2008 11:15 am
by JamesM
Change your compile line to "-fno-leading-underscores" instead of "-fleading-underscores". All C functions will have been compiled with a leading underscore, so to access them properly from asm you would have had to add one there, too, e.g. "global _kmain; call _kmain". The easiest way is to change the flag.

Re: undefined reference to 'kmain' ?

Posted: Fri Nov 28, 2008 5:51 pm
by quanganht
Err, I have cross-compiler. Oh hell no, I called 'gcc', not 'i586-elf-gcc' => is that the problem ?

From 'Same mistakes' - James Blunt
"I wonder where (hooo...)
Did I go wrong?" :lol:

Re: undefined reference to 'kmain' ?

Posted: Fri Nov 28, 2008 5:58 pm
by quanganht
The problem solved: I should call 'i586-elf-gcc' etc instead of 'gcc' :lol:

Re: undefined reference to 'kmain' ?

Posted: Thu Aug 05, 2010 8:04 am
by van7hu
Did anyone try: ld -T linker.ld -o kernel.bin kernel.o loader.o
rather than : ld -T linker.ld -o loader.o kernel.o
with this I get the same error :D
may be it will be useful for someone from Google