undefined reference to 'kmain' ?

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
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

undefined reference to 'kmain' ?

Post by quanganht »

I've done like this
http://wiki.osdev.org/Bare_bones

And it keep popping to my face like this
Image
"Programmers are tools for converting caffeine into code."
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: undefined reference to 'kmain' ?

Post 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
Last edited by piranha on Fri Nov 28, 2008 11:18 am, edited 1 time in total.
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: undefined reference to 'kmain' ?

Post 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.
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: undefined reference to 'kmain' ?

Post 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:
"Programmers are tools for converting caffeine into code."
User avatar
quanganht
Member
Member
Posts: 301
Joined: Fri May 16, 2008 7:13 pm
Location: Hanoi, Vietnam

Re: undefined reference to 'kmain' ?

Post by quanganht »

The problem solved: I should call 'i586-elf-gcc' etc instead of 'gcc' :lol:
"Programmers are tools for converting caffeine into code."
van7hu
Posts: 7
Joined: Wed Aug 04, 2010 10:18 am
Location: Hoà Bình,Việt Nam

Re: undefined reference to 'kmain' ?

Post 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
I will be here quite often !
Post Reply