Linux设备驱动程序安装fatal error: linux/module.h: No such file or directory

在做Linux设备驱动程序安装实验时,执行gcc -c mydev.c产生fatal error: linux/module.h: No such file or directory错误信息

mydev.c代码如下:

#ifndef __KERNEL__
#define __KERNEL__
#endif

#ifndef MODULE
#define MODULE
#endif

#define __NO_VERSION__

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

#if CONFIG_MODVERSIONS==1
#define MODVERSIONS
#include<linux/modversions.h>
#endif

#include<linux/fs.h>
#include<linux/wrapper.h>
#include<linux/types.h>
#include<asm/segment.h>

#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)*65535+(b)*256+(c))
#endif

/*Conditional compilation. LINUX_VERSION_CODE is
* the code (as per KERNEL_VERSION) of this version.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,2,0)
#include <asm/uaccess.h>	/*for put_user*/
#endif

#define SUCCESS 0
#define DEVICE_NAME "kueng_char_dev"
#d
这个错误提示是说在编译过程中找不到libavutil/time.h文件。根据引用,这个错误是由于缺少linux/perf_event.h文件导致的。可以根据引用中的方法,在libavutil目录下创建一个avconfig.h文件,然后在avconfig.h文件中添加以下内容: ``` /* Generated by ffconf */ #ifndef AVUTIL_AVCONFIG_H #define AVUTIL_AVCONFIG_H #define AV_HAVE_BIGENDIAN 0 #define AV_HAVE_FAST_UNALIGNED 0 #endif /* AVUTIL_AVCONFIG_H */ ``` 如果问题仍然存在,可以尝试根据引用中的方法进行操作。具体步骤是进入/ijkplayer-master/config目录,查看module-default.sh文件的最后一行是否包含以下内容: ``` export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-linux-perf" ``` 如果没有的话,可以手动添加这一行。然后执行以下命令: ``` cd config rm module.sh ln -s module-lite.sh module.sh ``` 这样应该能解决缺少libavutil/time.h文件的错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [/libavutil/timer.h:38:31: fatal error: linux/perf_event.h: No such file or directory](https://blog.csdn.net/wusejiege6/article/details/108310915)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* [fatal error: libavutil/avconfig.h: No such file...](https://blog.csdn.net/athrunsunny/article/details/122369052)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值