I\'m trying to compile the following program in Ubuntu. But I keep getting the error: \"stdio.h: No such file or directory\" error.
#include
The problem is you can't use printf() and stdio.h inside the kernel, and you don't use a main() function either. You need printk() and module.h
#include /* Needed by all modules */
#include
int init_module(void)
{
printk(KERN_INFO "Hello world\n");
return 0;
}
You should also have a exit()/cleanup() type function for when it unloads.
void clean_module(void)
{
printk(KERN_INFO "Cleaning and exiting\n");
}
Then load the functions for the module:
module_init(init_module);
module_exit(clean_module);