You are not logged in.
Pages: 1
Hi. So I was reading some online book about making kernel modules. So I got my code:
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
And 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
The console output is:
[frynio@archlinux kernel]$ make
make -C /lib/modules/4.7.1-1-ARCH/build M=/home/frynio/Desktop/dev/kernel modules
make[1]: Entering directory '/usr/lib/modules/4.7.1-1-ARCH/build'
make[1]: *** No rule to make target 'modules'. Stop.
make[1]: Leaving directory '/usr/lib/modules/4.7.1-1-ARCH/build'
make: *** [Makefile:4: all] Error 2
What am I doing wrong?
Offline
Hello Frynio, you most probably need to install linux-headers package.
Offline
Thank you, I'm so dumb, gosh
Offline
No problem
Please mark the thread as solved and enjoy your kernel hacking.
Offline
Pages: 1