Page 2 of 2

Re: Understanding Bare Bones

Posted: Mon Mar 02, 2009 6:47 pm
by gsingh2011
Ok so I finally got the following code to compile with errors. Basically, I want to clear the screen.

Code: Select all

#include "kernel.h"
#include <string.h>

// Screen dimensions (for default 80x25 console)
#define LINE_PITCH 160       // line width in bytes
#define LINE_COUNT 25

default_console::default_console()
{
    videoram = (volatile unsigned char *) 0xb8000;
    cursor = (volatile unsigned int *) 0xb903c;
    clear();
}

void default_console::clear()
{
    memset((void*)videoram, 0, LINE_PITCH*LINE_COUNT);
    locate(0,0);
    attr = 0x07;
}

void kmain( void* mbd, unsigned int magic )
{
	default_console();
	clear();
}
I get the errors when linking it:

Code: Select all

Object Files/loader.o: In function `loader':
Source Files/loader.s:(.text+0x14): undefined reference to `kmain'
Object Files/kernel.o: In function `default_console::clear()':
kernel.cpp:(.text+0x25): undefined reference to `memset'
kernel.cpp:(.text+0x40): undefined reference to `default_console::locate(int, int)'
Object Files/kernel.o: In function `default_console::self()':
kernel.cpp:(.text+0xb4): undefined reference to `__cxa_guard_acquire'
kernel.cpp:(.text+0xdd): undefined reference to `__cxa_guard_release'
kernel.cpp:(.text+0x108): undefined reference to `__cxa_guard_abort'
kernel.cpp:(.text+0x11f): undefined reference to `_Unwind_Resume'
Object Files/kernel.o:(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
My loader.s and linker script are the exact same as in the barebones tutorial. Sorry if these are all noob questions, but I simply don't have enough experience with OS programming to solve the errors on my own...

BTW, will this code work when it runs? Is it the correct code to clear the screen?

Re: Understanding Bare Bones

Posted: Tue Mar 03, 2009 1:42 am
by Combuster
Classic mistakes:
- Using header files you did not write yourself
- Mixing C headers with C++ code
- Using a language of which you know too little for OS development.
- Not building a GCC Cross-Compiler, not telling g++ to strip all platform dependencies.
- Not listening to what others said already

based on #2 and #3 (and partially #5), I'd say that OS development is too high a goal for now.