Page 1 of 1

HELP

Posted: Mon Sep 10, 2007 1:08 pm
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

Posted: Mon Sep 10, 2007 1:15 pm
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..

Posted: Mon Sep 10, 2007 1:31 pm
by Combuster
Looks like a frequently asked question to me - Read: GCC Cross-Compiler