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

源码:


**/*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

时间: 2024-10-09 22:42:06

linux/module.h: No such file or directory 内核模块编译过程的相关文章

Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法

错误描述 安装Redis 2.8.18时报错: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: #error "Newer version of jemalloc required"make[1]: *** [adlist.o] Error 1make[1]: Leaving directory `/data0/src/redis-2.6.2/src

编译Busybox时,出现错误fatal error: curses.h: No such file or directory

1 scripts/kconfig/mconf.c: In function ‘exec_conf’: 2 scripts/kconfig/mconf.c:481:2: warning: ignoring return value of ‘pipe’, declared with attribute warn_unused_result [-Wunused-result] 3 pipe(pipefd); 4 ^ 5 SHIPPED scripts/kconfig/zconf.tab.c 6 SH

CentOS: make menuconfig error: curses.h: No such file or directory

the problem  when use centos5 to build kernel or busybox step 1. Centos中关于 ncurses.h:no such file or directory错误的问题 http://blog.sina.com.cn/s/blog_9f1c09310101a668.html 原因是系统中没有安装ncurses这个库函数,从网上查了个能在Centos上解决这个问题的安装方式: yum install ncurses-devel ncur

jemalloc/jemalloc.h: No such file or directory

Redis 2.6.9 安装报错,提示: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directoryzmalloc.h:55:2: error: #error "Newer version of jemalloc required"make[1]: *** [adlist.o] Error 1make[1]: Leaving directory `/data0/src/redis-2.6.2/src'ma

lua.c:80:31: fatal error: readline/readline.h: No such file or directory

make linuxcd src && make linuxmake[1]: Entering directory `/root/lua/lua-5.3.2/src'make all SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline"make[2]: Entering directory `/root/lua/lua-5.3.2/src'gcc -std=gnu99 -O2 -Wa

fatal error: Python.h: No such file or directory 解决

[常见错误] fatal error: Python.h: No such file or directory 环境场景 系统: Parrot Linux软件: 系统python默认版本2.7 PyCharm默认版本Python3.5场景: Build pycrypto-2.6.1 失败提示: building 'Crypto.PublicKey._fastmath' extension x86_64-linux-gnu-gcc -pthread -fwrapv -Wall -Wstrict-p

Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No such file or directory

Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API. 本文为大家讲解的是Redis 2.8.18 安装报错 error: jemalloc/jemalloc.h: No such file or directory解决方法,感兴趣的同学参考下. 错误描述 安装Redis 2.8.18时报错: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or

curses.h: No such file or directory

嵌入式linux移植时,编译busybox或者内核时使用make menuconfig有时会遇到这个错误 Linux Error: curses.h: No such file or directory 这是因为缺少响应的依赖库 解决方法: CentOS :yum install ncurses-devel ncurses Ubuntu: sudo apt-get install libncurses5-dev libncursesw5-dev

error: openssl/md5.h: No such file or directory

出现:error: openssl/md5.h: No such file or directory 原因是openssl-devel没有安装,运行: yum install libssl-dev 就能够了 我用的Fodera找不到libssl-dev,就运行yum install openssl openssl-devel linux下apache+php安装常见问题 http://hi.baidu.com/easyphp/item/f0e4064c21679deea4c066c9 2) Ch