Undefined reference error for printf in Kernel Main process

Programming, for all ages and all languages.
Post Reply
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Undefined reference error for printf in Kernel Main process

Post 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.
Attachments
Ekran görüntüsü 2022-04-04 173750.png
M. Alp
kzinti
Member
Member
Posts: 898
Joined: Mon Feb 02, 2015 7:11 pm

Re: Undefined reference error for printf in Kernel Main proc

Post by kzinti »

That's because you didn't implement printf() anywhere, you implemented print().
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Undefined reference error for printf in Kernel Main proc

Post by Mehmetdev1 »

How can I implement printf?
M. Alp
Octocontrabass
Member
Member
Posts: 5512
Joined: Mon Mar 25, 2013 7:01 pm

Re: Undefined reference error for printf in Kernel Main proc

Post by Octocontrabass »

Are you sure you want to implement printf? It looks like you want to call print instead of printf.
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Undefined reference error for printf in Kernel Main proc

Post by Mehmetdev1 »

I want to call printf, not print.
M. Alp
Octocontrabass
Member
Member
Posts: 5512
Joined: Mon Mar 25, 2013 7:01 pm

Re: Undefined reference error for printf in Kernel Main proc

Post by Octocontrabass »

Why do you want to call printf instead of the print function you've already written?
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Undefined reference error for printf in Kernel Main proc

Post by Mehmetdev1 »

If I Call the Print Function, It Gives an Error.
M. Alp
Octocontrabass
Member
Member
Posts: 5512
Joined: Mon Mar 25, 2013 7:01 pm

Re: Undefined reference error for printf in Kernel Main proc

Post by Octocontrabass »

What is the error?
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

Re: Undefined reference error for printf in Kernel Main proc

Post 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);

{

}

}
M. Alp
Post Reply