- Why exactly do you need a cross compiler? What purpose does it serve?
- So if you start up a kernel, what does it mean by porting the C libraries to your OS? And why do you need it?
- The kernel is used to do all the work for the OS, but how does it do the work without stdio.h or stdlib.h? How does the porting libraries work exactly, how does it help?
Clarification of A cross compiler and C libaries?
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Clarification of A cross compiler and C libaries?
Hi, i read the wiki article about cross compiling, and what its needed for. I have a working boot-loader, and am starting the kernel. However I am extremely confused. so here are my questions;
Re: Clarification of A cross compiler and C libaries?
Hi,
When you start writing a kernel, you have no C library available to help you. You will therefore need to write a subset of it - memcpy, memset, strcpy etc. . What subset you write is up to you, but you won't be able to write the whole lot - it's massive! Eventually you'll get to the point where you're starting user processes, and these will need a C library to link against. At that point, you port a full C library. You're nowhere near there yet.
Without stdio.h and stdlib.h - you'll have to write that functionality yourself. There are tutorials and articles on how to use serial ports and write to the screen - you have to write everything yourself.
Cheers,
James
A cross compiler helps by sanitising your environment and ensuring that you don't accidentally have code brought in by your compiler that you don't expect. Although, I'm not fully convinced of its immediate utility to a newcomer using Linux.theelitenoob wrote:Hi, i read the wiki article about cross compiling, and what its needed for. I have a working boot-loader, and am starting the kernel. However I am extremely confused. so here are my questions;
- Why exactly do you need a cross compiler? What purpose does it serve?
- So if you start up a kernel, what does it mean by porting the C libraries to your OS? And why do you need it?
- The kernel is used to do all the work for the OS, but how does it do the work without stdio.h or stdlib.h? How does the porting libraries work exactly, how does it help?
When you start writing a kernel, you have no C library available to help you. You will therefore need to write a subset of it - memcpy, memset, strcpy etc. . What subset you write is up to you, but you won't be able to write the whole lot - it's massive! Eventually you'll get to the point where you're starting user processes, and these will need a C library to link against. At that point, you port a full C library. You're nowhere near there yet.
Without stdio.h and stdlib.h - you'll have to write that functionality yourself. There are tutorials and articles on how to use serial ports and write to the screen - you have to write everything yourself.
Cheers,
James
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Clarification of A cross compiler and C libaries?
Oh, ok, so basically, i can start writing my kernel, but wherever I need a function, such as memcpy, or printf, i have to implement them myself, correct? So i don't need to link or port a library if I don't want to? Also, say I need printf, how would I make it print out to the screen? Just as an example.
Re: Clarification of A cross compiler and C libaries?
Yes you need to write them yourself.
To print to the screen you should read up on the wiki. It is dead easy.
To print to the screen you should read up on the wiki. It is dead easy.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Clarification of A cross compiler and C libaries?
Ok, I'll look into it, thanks for the help mate. Also one last question, is it possible to completely write the OS, without porting any libraries?
Re: Clarification of A cross compiler and C libaries?
Of course, you make your own libraries.
-
- Posts: 16
- Joined: Wed Aug 24, 2011 11:19 am
Re: Clarification of A cross compiler and C libaries?
Ok, good to know, time to get started!
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: Clarification of A cross compiler and C libaries?
Yo:
What about it did you not understand? Just for my own enlightenment, nothing else
I thought that the wiki article was phrased excruciatingly verbosely and painstakingly optimised for even the least experienced of people. Just to clarify, did you read this specific article here...?theelitenoob wrote:Hi, i read the wiki article about cross compiling, and what its needed for...
- Why exactly do you need a cross compiler? What purpose does it serve?
What about it did you not understand? Just for my own enlightenment, nothing else
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.