linux 编译 内核模块 头文件,linux/module.h: No such file or directory 内核模块编译过程...

1、缺少Linux kernel头文件

To install just the headers in Ubuntu:

sudo apt-get install linux-headers-$(uname -r)

To install the entire Linux kernel source in Ubuntu:

sudo apt-get install linux-source

Note that you should use the kernel headers that match the kernel you are running.

2、内核模块编译过程ubuntu

源码 hello.c :

#include

#include

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)

{

printk(KERN_ALERT "Hello, world\n");

return 0;

}

static void hello_exit(void)

{

printk(KERN_ALERT "Goodbye, cruel world\n");

}

module_init(hello_init);

module_exit(hello_exit);

Makefile文件

# at first type on ur terminal that $(uname -r) then u will get the version..

# that is using on ur system

obj-m +=

你可能感兴趣的:(linux,编译,内核模块,头文件)