Where did my printf go?

So your kernel is nothing but a simple
/* my test kernel */
void main(void)
But it wont link! It complains of missing printf.

When you write an OS, the compiler has several libraries of function calls (printf, fopen, fread, memmove, strcmp, etc) that are built to run on that particular operating system. Basically, you are trying to use a routine that is not part of your os.

You have to write your own c library containing those calls for them to work on your operating system. see So whats this libc thing?


So whats this libc thing?

The libc is the compilers c library of function calls. If you want to use routines like printf, strcmp, strcopy, memmove, getch, toupper, etc in your operating system, you have to either port them over from an existing C library, or write them yourself.

This includes the appropriate stdlib.h, string.h files as well as the routines themselves.


What C libraries exist for me to use?

There are some existing C libraries you can port to your OS (basically you just recompile them).

Be aware some C libraries are copyright and some are free, some are gnu.

There exists a few GNU C libraries you can use. Be carefull not to use all the functions, as many have low level constraints (fopen, fread, etc) whereas a lot of it you can use, eg: memmove, isalpha, strcmp, etc.

Visual C comes with source for its C library, but ofcourse it is copyright so be veeeeeery carefull if you want to err try and use that as your own library source.