首页 > 系统服务 > 详细

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

时间:2016-05-05 21:50:55      阅读:3493      评论:0      收藏:0      [点我收藏+]

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

源码:

**/*source file name is basic.c */**

#include <linux/init.h>

#include <linux/module.h>

/*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 +=basic.o

KDIR =//usr/src/linux-headers-3.13.0-44-generic

all:

$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:

rm -rf *.o *.ko *.mod.* *.symvers *.order

内核模块运行:

$sudo insmode basic.ko

$dmesg           ==> u will get the output

$sudo rmmod basic.ko

$dmesg

参考链接:

  http://stackoverflow.com/questions/16919512/linux-module-h-no-such-file-or-directory

 

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

原文:http://www.cnblogs.com/zhangjy6/p/5462644.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!