Standard Library

the third part of the third chapter in our series on How to Write an Operating System


Creating a library

The standard library provides a level of abstraction to system calls and functionality that all operating systems should provide (according to the ANSI standard). For portability and consistency, an operating system should provide access to functions in the C standard library, at least at some level. This is usually done through either static or shared libraries, which can be created with the ar command:

ar vq libc.a strlen.o strcpy.o
for example.

Then, when linking applications for use by your kernel, specify that it should statically link (for now, until your operating system can handle shared libraries) the application with your standard library:

ld -o app.elf app.o -lc