c – linux / kernel.h:没有这样的文件或目录

我将在Ubuntu 10.10中编写一个Hello World模块(内核为2.6.35-28-generic).标题位于:
/usr/src/linux-headers-2.6.35-28-generic

你好ç:

#include <linux/kernel.h> 
#include <linux/module.h>

int init_module(void)
{
    printk("Hello,world\n");
    return 0;
}

void cleanup_module(void)
{
    printk("Goodbye\n");
}

和Makefile:

CC = gcc
CFLAGS = -Wall -DMODULE -D__KERNEL__
hello.o: hello.c
    $(CC) $(CFLAGS) -c hello.c
    echo insmod hello.o to install
    echo rmmod to delete

make时出错:

hello.c:1: Fatal error: linux/kernel.h : No such file or directory
compilation terminated.

我该如何解决这个问题?

解决方法

你有/usr/src / linux符号链接到你的/usr/src/linux-headers-2.6.35-28-generic吗?
如果没有,则使用以下命令创建一个
# cd /usr/src
# ln -sfn linux-headers-2.6.35-28-generic linux

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...