Why doesnt my print function work?

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
madpickle
Posts: 3
Joined: Thu Dec 01, 2022 5:48 pm
Libera.chat IRC: madpickle
Location: The Milky Way Galaxy
Contact:

Why doesnt my print function work?

Post 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.
Proud user of GCC.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: Why doesnt my print function work?

Post 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.
madpickle
Posts: 3
Joined: Thu Dec 01, 2022 5:48 pm
Libera.chat IRC: madpickle
Location: The Milky Way Galaxy
Contact:

Re: Why doesnt my print function work?

Post by madpickle »

I already solved this issue, but I had no way to delete a topic while it was waiting for moderator approval...
Proud user of GCC.
Post Reply