C++ Kernel and Grub

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
FireDemon

C++ Kernel and Grub

Post 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.
Mr_Spam

Re:C++ Kernel and Grub

Post 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.
FireDemon

Re:C++ Kernel and Grub

Post 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...
Slasher

Re:C++ Kernel and Grub

Post by Slasher »

I think you need to compile and link the kernel to an Elf file
FireDemon

Re:C++ Kernel and Grub

Post by FireDemon »

How do you output ELF. I use DJGPP and NASM.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:C++ Kernel and Grub

Post 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
-- Stu --
FireDemon

Re:C++ Kernel and Grub

Post 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 :-\ :-* :'(
Post Reply