OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:03 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Undefined reference error for printf in Kernel Main process
PostPosted: Mon Apr 04, 2022 8:50 am 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
Code:
#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
Ekran görüntüsü 2022-04-04 173750.png [ 45.9 KiB | Viewed 1552 times ]

_________________
M. Alp
Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 9:04 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 898
That's because you didn't implement printf() anywhere, you implemented print().

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 9:07 am 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
How can I implement printf?

_________________
M. Alp


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 10:25 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Are you sure you want to implement printf? It looks like you want to call print instead of printf.


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 11:00 am 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
I want to call printf, not print.

_________________
M. Alp


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 11:12 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
Why do you want to call printf instead of the print function you've already written?


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 11:43 am 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
If I Call the Print Function, It Gives an Error.

_________________
M. Alp


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 11:44 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
What is the error?


Top
 Profile  
 
 Post subject: Re: Undefined reference error for printf in Kernel Main proc
PostPosted: Mon Apr 04, 2022 12:37 pm 
Offline

Joined: Fri Apr 01, 2022 10:06 am
Posts: 23
Location: Türkiye, Uşak/Merkez
Thank goodness I solved the error, the code to solve the error:
Code:
#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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group