Linux代码问题,请高手帮我看看!在线等!如果改对了再加50分。

来源:百度知道 编辑:UC知道 时间:2024/06/25 19:15:10
#include <linux/kernel.h>
#include <linux/module.h>
#if CONFIG_MODVERSIONS == 1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
Int init_module()
{
Printk(“HELLO! This is a testing module! \n”);
Return 0;
}
Void cleanup_module()
{
Printk(“Sorry! The testing module is unloading now! \n”);
}
然后我输入gcc -o2 -Wall -DMODULE -D__KERNEL__ -c testmodule.c进行编译。终端提示有:
错误:linux/module.h 没有这个文件或目录
警告:在函数init_module中,隐式声明函数printk
testmodule.c:10: 错误:expected expression before“)”token
testmodule.c:11: 警告:在有返回值的函数中,控制流程到达函数尾。
这四个问题,应该怎么改?
问下,那应该怎么改这段代码呢?我马上要答辩了,可是一直弄不出来。。。大家帮帮忙!
请问5楼,那个路径具体怎么添加到GCC中去啊?具体代码是什么?
还有我代码不能运行会不会和编译器有关?

用“-I(include path)”把linux/module.h的路径添加到gcc编译的命令上去试试。
其实最好能自己写一个makefile

再给你一个链接:
http://cache.baidu.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380146d8d8b492c93cf13d9735b361b31a5a660220d01d9c279671cee1301afa37634200454b49ac2834ad8b1852858d2616b2e08c31c528516f09610629f77875a98f04abeede733e3fa898d88&p=c063cd15d9c350fc57ede63558&user=baidu

你看看你的 /usr/include/linux 里面有没有kernel.h和module.h

找到个绝对路径吧 前段时间我写php连接mysql的时候也是这个问题
很烦躁的

linux/module.h是因为你没有软连接

语法错误。