linux 关于编译模块缺少config.h而产生错误的问题

本文介绍了解决在2.6.18及更高版本的Linux内核中编译模块时出现的linux/config.h文件缺失问题的具体方法。通过修改源代码中的包含路径或将config.h替换为autoconf.h来规避该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题来源:
Compiling for /home/dsr-uu-0.2
make -C /lib/modules/2.6.18-1.2798.fc6/build SUBDIRS=/home/dsr-uu-0.2 modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-1.2798.fc6-i686'
  CC [M]  /home/dsr-uu-0.2/dsr-module.o
/home/dsr-uu-0.2/dsr-module.c:16:26: 错误:linux/config.h:没有那个文件或目录
make[2]: *** [/home/dsr-uu-0.2/dsr-module.o] 错误 1
make[1]: *** [_module_/home/dsr-uu-0.2] 错误 2
make[1]: Leaving directory `/usr/src/kernels/2.6.18-1.2798.fc6-i686'
make: *** [dsr.ko] 错误 2
解决方法;
我看的方法是从网上看到的看到的。呵呵
1)先把我实验正确的方法贴出:The file include/linux/config.h has been removed from 2.6.18 kernel. So remember this if you build your favorite module against the new 2.6.19 kernel and you get an error。 Thats because there is no more include/linux/config.h file in 2.6.19. This is from the Changelog:

Quote:

Author: Dave Jones <someone@someplace.com>
Date: Mon Oct 9 19:13:51 2006 -0400

[HEADERS] Put linux/config.h out of its misery.

Signed-off-by: Dave Jones <someone@someplace.com>



Author: Paul Mundt <nameremoved@a-linux-company.org>
Date: Tue Oct 3 13:19:02 2006 +0900

sh: Kill off remaining config.h references.

A few of these managed to sneak back in, get rid of them once
and for all.

解决方法:
The reason I posted this is for people who have the kernel sources installed and are trying to build a module against the sources and are getting the error I mentioned. You wouldn't be trying to build a module for the 2.6.19 kernel unless you had the sources installed.

Actually there is not much to the file:

Code:
#ifndef _LINUX_CONFIG_H

#define _LINUX_CONFIG_H

/* This file is no longer in use and kept only for backward compatibility.

* autoconf.h is now included via -imacros on the commandline

*/

#include <linux/autoconf.h>



#endif



So if you have problems you could probably just add to code here to your module.c file.



我也就是和上面的一样,但是程序还是不认上面的补丁程序;所以,我亲自手动把所有包含config.h的源文件改成autoconf.h。这样就没有出错了。但是还有人说2.6.23后没有了autoconf.h了。那就需要再先看看下面的方法有用没?

2)well the .h files are not from the main kernel package ,they are from the devel package(unless you built it yourself)

if kernel-devel(or -source depending on distro) isn't installed there wouldn't be any useful includes.

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值