Page 1 of 1

C++ Kernel and Grub

Posted: Sat Jan 11, 2003 12:55 pm
by FireDemon
I made a kernel called kernel_cpp.cpp
I use:
set DJGPP=C:\DJGPP\DJGPP.ENV
set PATH=C:\DJGPP\BIN;%PATH%

nasm -f aout kernel.asm -o kernel.o
gxx -c kernel_cpp.cpp -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions
ld -T link.ld -o kernel.bin kernel.o kernel_cpp.o
copy kernel.bin A:\kernel.bin

to compile it,but grub does not run it. Is the top the correct and how can you build bin files for grub.

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 1:07 pm
by Mr_Spam
I think that u have to put in a multi-boot header into the start of the kernel? i'm not sure.

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 2:50 pm
by FireDemon
I did that and it still keeps giving me:

Booting 'Simplified OS'

root (fd0)
Filesystem type is fat, using whole disk
kernel /kernel.bin

Error 13: Invalid or unsupported executable format

Press any key to continue...

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 2:54 pm
by Slasher
I think you need to compile and link the kernel to an Elf file

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 2:58 pm
by FireDemon
How do you output ELF. I use DJGPP and NASM.

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 3:47 pm
by df
you can create a flat binary file with ld --oformat binary etc. read the grub tutorial at;

http://osdev.berlios.de/grub.html#multiboot

scroll down to yo see the heading
DJGPP COFF kernels and other file formats

Re:C++ Kernel and Grub

Posted: Sat Jan 11, 2003 4:32 pm
by FireDemon
I fixed the problem.
The main reason was that the global variables made an offset to the main function.

:) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-* :'(