moving kernel from C to C++
Posted: Sat Jul 26, 2008 5:05 pm
At first "Hello world!" to everybody since it is my first post on this forum.
I'm using James Molloy boot.s (http://www.jamesmolloy.co.uk/tutorial_h ... nesis.html) with one exception I changed "main" to "kmain".
My kmain.c is:
My kmain.cpp is:
Output of "nm kmain.o" for both files gives:
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -c
options passed to linker:
LDFLAGS=-Tlink.ld
options passed to nasm:
ASFLAGS=-felf
options passed to g++:
CPPFLAGS=-nostartfiles -nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -c
I'm using linux as development platform. Does anybody know why I can't link against kmain.o file generated by g++?
I'm using James Molloy boot.s (http://www.jamesmolloy.co.uk/tutorial_h ... nesis.html) with one exception I changed "main" to "kmain".
My kmain.c is:
Code: Select all
struct multiboot;
int kmain(struct multiboot *mboot_ptr){
return 0xDEAD0000;
}Code: Select all
struct multiboot;
extern "C" int kmain(struct multiboot *mboot_ptr){
return 0xDEAD0000;
}Linking with c version goes perfectly fine, but when I try to link with c++ version linker reports:00000000 T kmain
options passed to gcc:boot.o: In function `start':
boot.s:(.text+0x1f): undefined reference to `kmain'
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -c
options passed to linker:
LDFLAGS=-Tlink.ld
options passed to nasm:
ASFLAGS=-felf
options passed to g++:
CPPFLAGS=-nostartfiles -nostdlib -nostdinc -fno-builtin -fno-stack-protector -Wall -c
I'm using linux as development platform. Does anybody know why I can't link against kmain.o file generated by g++?