HELP

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
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

HELP

Post by suthers »

Hey well I've been trying to make an OS for about a year now
but i have never been able to make one link.

I use this command line to assemble:
nasm -f elf -o start.o start.asm

This is my asm code:

[BITS 16]

global start
start:
extern _main
call _main
jmp $

times 510-($-$$) db 0
dw 0xAA55

I use this command line to compile:
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -c -o main.o main.cpp

This is my c code:

int main()
{
}

until there i don't get any errors,
but when i try to link with this command line:
ld -o kernel.bin start.o main.o

and it gives me the following error:

C:\Dev-Cpp\bin\ld.exe: warning: cannot find entry symbol _mainCRTStartup; defaul
ting to 00401000
main.o(.text+0xf):main.cpp: undefined reference to `_alloca'
main.o(.text+0x14):main.cpp: undefined reference to `__main'

can anybody tell me what to do (it getting really annoying trying to make an OS and not getting further than a "Hello World!" boot loader.
Thanks in advance,

Jules
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Post by salil_bhagurkar »

Thats probably due to the libraries that are getting linked by default to the os. You are also not specifying the output format of the os image.

There are just too many basic steps missing and you won't get anywhere this way.. I can tell you a perfect and most popular source to learn about this.

Search for bran's kernel development tutorials on google. Download the tutorial and go step by step through it.. It's easy to understand and will teach you linking also..
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:

Post by Combuster »

Looks like a frequently asked question to me - Read: GCC Cross-Compiler
"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 ]
Post Reply