Linux模块编译问题
时间:2007-12-04
来源:互联网
想整理下设备驱动这块的知识。
结果用模块编译的时候出现了如下的错误:
源文件:
//mydisk.c
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
#include <linux/sched.h>
#include "mydisk.h"
struct file_operations mydisk_fops={
open: generic_file_open,
write: generic_file_write,
release: generic_file_release,
ioctl: generic_file_ioctl,
llseek: generic_file_llseek,
read: generic_file_read,
};
int init_modules(void)
{
printk(KERN_INFO "MOUNT IDE DISK...\N");
if(register_blkdev(DEV_MAJOR,DEV_NAME,&mydisk_fops) <0)
{
printk(KERN_INFO "Couldn't register a device.\n");
return -1;
}
return 0;
}
int cleanup_modlue(void)
{
if(unregister_blkdev(DEV_MAJOR,DEV_NAME))
printk("Failed to unregister device.\n");
else
printk("Device uninstalled.\n");
}
MODULE_LICENSE("GPL");
//mydisk.h
#ifndef _MYDISK_H_
#define DEV_MAJOR 3
#define DEV_NAME "IDEDISK"
#endif
编译:
gcc -c mydisk.c -D_KERNEL_ -DMODULE -O2 -g -Wall -o mydisk.o
错误提示:
In file included from /usr/include/linux/sched.h:14
from /usr/include/linux/mm.h:4
from /usr/include/linux/locks.h:5
from /usr/include/linux/devfs_fs_kernel.h:6,
from mydisk.c:4
/usr/include/linux/timex.h:173: field 'time' has incomplete type
/usr/include/linux/timex.h:188: confused by earlier errors, bailing out
///////////////////////////////////////
1.这个问题怎么解决?
2.以前没写过Linux的驱动,甚至程序也不怎么写过,想问一下,模块编译时候的头文件包含到底要怎么办,都弄不太清楚。
希望前辈指点。谢谢。。。~~~
结果用模块编译的时候出现了如下的错误:
源文件:
//mydisk.c
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>
#include <linux/sched.h>
#include "mydisk.h"
struct file_operations mydisk_fops={
open: generic_file_open,
write: generic_file_write,
release: generic_file_release,
ioctl: generic_file_ioctl,
llseek: generic_file_llseek,
read: generic_file_read,
};
int init_modules(void)
{
printk(KERN_INFO "MOUNT IDE DISK...\N");
if(register_blkdev(DEV_MAJOR,DEV_NAME,&mydisk_fops) <0)
{
printk(KERN_INFO "Couldn't register a device.\n");
return -1;
}
return 0;
}
int cleanup_modlue(void)
{
if(unregister_blkdev(DEV_MAJOR,DEV_NAME))
printk("Failed to unregister device.\n");
else
printk("Device uninstalled.\n");
}
MODULE_LICENSE("GPL");
//mydisk.h
#ifndef _MYDISK_H_
#define DEV_MAJOR 3
#define DEV_NAME "IDEDISK"
#endif
编译:
gcc -c mydisk.c -D_KERNEL_ -DMODULE -O2 -g -Wall -o mydisk.o
错误提示:
In file included from /usr/include/linux/sched.h:14
from /usr/include/linux/mm.h:4
from /usr/include/linux/locks.h:5
from /usr/include/linux/devfs_fs_kernel.h:6,
from mydisk.c:4
/usr/include/linux/timex.h:173: field 'time' has incomplete type
/usr/include/linux/timex.h:188: confused by earlier errors, bailing out
///////////////////////////////////////
1.这个问题怎么解决?
2.以前没写过Linux的驱动,甚至程序也不怎么写过,想问一下,模块编译时候的头文件包含到底要怎么办,都弄不太清楚。
希望前辈指点。谢谢。。。~~~
作者: sfezst 发布时间: 2007-12-04
希望大家帮助下那。。。。

作者: sfezst 发布时间: 2007-12-04
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28