linux内核模块编译问题
时间:2011-10-25
来源:互联网
我在网上copy了别人的一个内核helloworld模块,具体代码如下:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
int init_module(void)
{
printk("<1>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_ALERT "Goodbye world 1.\n");
}
makefile如下:
TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc-3.0
${TARGET}.o: ${TARGET}.c
.PHONY: clean
clean:
rm -rf {TARGET}.o
编译时总出现如下错误:
/lib/modules/2.6.32-34-generic/build/include/linux/bitops.h:17:24: error: asm/bitops.h: 没有那个文件或目录
类似的有好几条,还有
/lib/modules/2.6.32-34-generic/build/include/linux/thread_info.h:82: error: dereferencing pointer to incomplete type
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:319: error: expected specifier-qualifier-list before ‘Elf_Sym’
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:455: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from hello.c:1:
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:712: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
求高手指教。
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
int init_module(void)
{
printk("<1>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_ALERT "Goodbye world 1.\n");
}
makefile如下:
TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc-3.0
${TARGET}.o: ${TARGET}.c
.PHONY: clean
clean:
rm -rf {TARGET}.o
编译时总出现如下错误:
/lib/modules/2.6.32-34-generic/build/include/linux/bitops.h:17:24: error: asm/bitops.h: 没有那个文件或目录
类似的有好几条,还有
/lib/modules/2.6.32-34-generic/build/include/linux/thread_info.h:82: error: dereferencing pointer to incomplete type
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:319: error: expected specifier-qualifier-list before ‘Elf_Sym’
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:455: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
In file included from hello.c:1:
/lib/modules/2.6.32-34-generic/build/include/linux/module.h:712: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
求高手指教。
作者: emeis 发布时间: 2011-10-25
引用楼主 emeis 的回复:
我在网上copy了别人的一个内核helloworld模块,具体代码如下:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
int init_module(void)
{
printk("<1>Hello ……
可能内核版本不兼容。 我在网上copy了别人的一个内核helloworld模块,具体代码如下:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
int init_module(void)
{
printk("<1>Hello ……
作者: linwhwylb 发布时间: 2011-10-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28