QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1134|回复: 2

一个关于驱动的问题,谢谢

[复制链接]
发表于 2005-4-10 11:46:10 | 显示全部楼层 |阅读模式
我正在学习编写驱动程序。
//hello.c

#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif

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

MODULE_LICENSE("GPL");
#ifdef CONFIG_SMP
#define __SMP__
#endif

#include <linux/kernel.h>

static int init_module(){
        printk("Hello,World!\n");
        return 0;
}

static void cleanup_module(){
        printk("Bye!\n");
}

gcc -c -I/usr/src/linux/include hello.c后

运行命令
insmod hello.o
出现如下错误
hello.o: kernel-module version mismatch
        hello.o was compiled for kernel version 2.4.20
        while this kernel is version 2.4.20-8.
这是怎么回事?
我的系统是RH9.0
发表于 2005-4-12 16:43:19 | 显示全部楼层
内核版本不匹配, -I后面的src不是你正在运行的kernel source所以才会游这样的问题。
回复

使用道具 举报

 楼主| 发表于 2005-4-15 09:22:30 | 显示全部楼层
谢谢 搞定了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-9-29 05:44 , Processed in 0.039811 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表