I am trying to compile the Linux kernel: http://tldp.org/LDP/lkmpg/2.6/html/lkmpg.html
I have a simple hello world program hello-1.cpp
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
return 0;
}
void cleanup_module(void)
{
}
But I am trying to build it using the Makefile:
obj-m += hello-1.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
I get a couple of errors.
make -C /home/pacman/linux-2.6.34.11/2.6.35.6-45.fc14.i686/build M=/home/pacman/p1 modules
make: *** /home/pacman/linux-2.6.34.11/2.6.35.6-45.fc14.i686/build: No such file or directory. Stop.
make: * [all] Error 2
Am I forgetting to define something?
The basic way is to add the code to the kernel source tree and recompile the kernel. A more efficient way is to do this is by adding code to the kernel while it is running. This process is called loading the module, where module refers to the code that we want to add to the kernel.
An emergency condition; the system is probably dead. 1. KERN_ALERT. A problem that requires immediate attention.
Rename hello-1.cpp to hello-1.c (modules must be written in C) and add the lines:
module_init(init_module);
module_exit(cleanup_module);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With