I had some code that worked fine, but then I decided to put it in a header file and now its not working. This is my first time using my own header files so I'm assuming I made a beginner mistake somewhere...
/* kernel.c */
#define SCRWIDTH 200
#define SCRHEIGHT 1200
#include "io.h"
void kmain( void* mbd, unsigned int magic )
{
volatile unsigned char* videoram = (volatile unsigned char *) 0xb8000;
const char string[] = "Hi";
clear(videoram);
printstr(string, videoram);
}
/* io.h */
#ifndef IO_H
#define IO_H
extern void clear(volatile unsigned char *videoram);
extern void printstr(const char *string, volatile unsigned char *videoram);
#endif
/* io.c */
void clear(volatile unsigned char *videoram)
{
int i, j;
for(i = 0; i < SCRHEIGHT; i++)
{
for(j = 0; j < SCRWIDTH; j++)
{
videoram[2*i] = 32;
videoram[1+(2*i)] = 0x07;
}
}
}
void printstr(const char *string, volatile unsigned char *videoram)
{
int i = 0;
while(string[i] != '\0')
{
videoram[2*i] = string[i];
videoram[1+(2*i)] = 0x07;
i++;
}
}
It compiles fine, but I'm getting the error from my linker:
kernel.c:(.text+0x1e): undefined reference to `clear'
kernel.c:(.text+0x30): undefined reference to `printstr'
I'm using gcc as my compiler and LD as my linker.