Compiling C++ Kernel with objects
Posted: Tue Jul 27, 2004 5:29 pm
Hi,
I've been reading some info on the osfaqs2 wiki, and have started with the bare bones C++ kernel available.
Managed to successfully build the kernel with the gcc cross-compiler using instructions from that wiki too, and have booted it with GRUB using Bochs.
Now I've created a simple class for writing to video, but I'm having a lot of problems compiling everything.
I figure would just compile each .cpp file separately for now (haven't gotten onto a Makefile), and then run ld, passing it all the final .o files.
My compilation commands are:
i586-elf-as -o loader.o loader.asm
i586-elf-gcc -o kernel.o -c kernel.cpp -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
i586-elf-gcc -o kernel_video.o -c kernel_video.cpp -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
However, "i586-elf-ld -T linker.ld -o kernel.bin kernel.o loader.o kernel_video.o" gives:
kernel.o(.text+0xf): In function `_main':
: undefined reference to `kvid'
.....
kernel.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
Part of my kernel.cpp is as follows:
#include "kernel_video.h"
.....
void main(...) {
KernelVideo kvid;
kvid.WriteLine(".....");
...
}
I don't know where the __gxx_XXX stuff is coming from, since it was supposed to be just base gcc/g++ with no libraries or anything. And I'm not very experienced with all the subtleties of GCC, so very easy for me to go astray ;-)
Thanks for any help you people can provide me with =)
I've been reading some info on the osfaqs2 wiki, and have started with the bare bones C++ kernel available.
Managed to successfully build the kernel with the gcc cross-compiler using instructions from that wiki too, and have booted it with GRUB using Bochs.
Now I've created a simple class for writing to video, but I'm having a lot of problems compiling everything.
I figure would just compile each .cpp file separately for now (haven't gotten onto a Makefile), and then run ld, passing it all the final .o files.
My compilation commands are:
i586-elf-as -o loader.o loader.asm
i586-elf-gcc -o kernel.o -c kernel.cpp -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
i586-elf-gcc -o kernel_video.o -c kernel_video.cpp -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
However, "i586-elf-ld -T linker.ld -o kernel.bin kernel.o loader.o kernel_video.o" gives:
kernel.o(.text+0xf): In function `_main':
: undefined reference to `kvid'
.....
kernel.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
Part of my kernel.cpp is as follows:
#include "kernel_video.h"
.....
void main(...) {
KernelVideo kvid;
kvid.WriteLine(".....");
...
}
I don't know where the __gxx_XXX stuff is coming from, since it was supposed to be just base gcc/g++ with no libraries or anything. And I'm not very experienced with all the subtleties of GCC, so very easy for me to go astray ;-)
Thanks for any help you people can provide me with =)