Page 1 of 1

Why doesnt my print function work?

Posted: Thu Dec 01, 2022 6:33 pm
by madpickle
I'm following Daedalus Community's [url="https://www.youtube.com/watch?v=EpFUzjYehxs"]Making an OS (x86)[/url] tutorial.
Ive gotten to chapter 7, where you start writing the kernel in C. I'm trying to program a print function, but it doesn't work... And the stack trace doesn't give a clue...

Theres only one error.

Code: Select all

kernel.c:31: undefined reference to `_GLOBAL_OFFSET_TABLE_'


Here's the code:

Code: Select all

void print(char text[]) {
	unsigned int i = 0;
	unsigned int addr = 753664; // 0xb8000 in hex
	while (text[i] != 0) {
		*(char*)addr = text[i];
		i+=1;
		addr+=2;
	}
	return;
}

extern void main() {
	print("test");
	return;
}
I'm definitely a beginner, so this may just be a stupid mistake.
Any help would be appreciated, Thanks.

Re: Why doesnt my print function work?

Posted: Sun Dec 04, 2022 11:18 pm
by Octocontrabass
madpickle wrote:I'm following Daedalus Community's Making an OS (x86) tutorial.
Be warned: most tutorials have bugs. (Since I personally can't sit through a video tutorial, I couldn't say how good or bad this one is.)
madpickle wrote:

Code: Select all

kernel.c:31: undefined reference to `_GLOBAL_OFFSET_TABLE_'
Doesn't that tutorial say you need to use a cross-compiler? This error means you're not using a cross-compiler.

Re: Why doesnt my print function work?

Posted: Mon Dec 05, 2022 11:07 am
by madpickle
I already solved this issue, but I had no way to delete a topic while it was waiting for moderator approval...