Page 1 of 1

Undefined reference error for printf in Kernel Main process

Posted: Mon Apr 04, 2022 8:50 am
by Mehmetdev1

Code: Select all

#include <stdio.h>

void print(char* str)
{

 unsigned short* VideoMemory = (unsigned short*)0xb8000;

 for(int i = 0; str[i] != '\0'; ++i)
 VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];

}

extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
 printf("Kapiler İsletim Sistemi");

 while(1);

{

}

}
Hello, I am getting an undefined reference error for printf in the Kernel Main process, I will post the codes and the screenshot of the error here.

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 9:04 am
by kzinti
That's because you didn't implement printf() anywhere, you implemented print().

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 9:07 am
by Mehmetdev1
How can I implement printf?

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 10:25 am
by Octocontrabass
Are you sure you want to implement printf? It looks like you want to call print instead of printf.

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 11:00 am
by Mehmetdev1
I want to call printf, not print.

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 11:12 am
by Octocontrabass
Why do you want to call printf instead of the print function you've already written?

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 11:43 am
by Mehmetdev1
If I Call the Print Function, It Gives an Error.

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 11:44 am
by Octocontrabass
What is the error?

Re: Undefined reference error for printf in Kernel Main proc

Posted: Mon Apr 04, 2022 12:37 pm
by Mehmetdev1
Thank goodness I solved the error, the code to solve the error:

Code: Select all

#include <stdio.h>

void print(char* str)
{

unsigned short* VideoMemory = (unsigned short*)0xb8000;

for(int i = 0; str[i] != '\0'; ++i)
VideoMemory[i] = (VideoMemory[i] & 0xFF00) | str[i];

}

extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{
print("Kapiler İsletim Sistemi");

while(1);

{

}

}