linux 关于编译模块缺少config.h而…

来源:互联网 发布:交换查看mac地址命令 编辑:程序博客网 时间:2024/05/22 15:00

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

分类: 基于类linux的开发嵌入式系统的研究与开发2009-08-02 22:48 3155人阅读

问题来源:
Compiling for /home/dsr-uu-0.2
make -C /lib/modules/2.6.18-1.2798.fc6/buildSUBDIRS=/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 removedfrom 2.6.18 kernel. So remember this if you build your favoritemodule against the new 2.6.19 kernel and you get an error。 Thatsbecause 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 itsmisery.

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 sourcesinstalled and are trying to build a module against the sources andare getting the error I mentioned. You wouldn't be trying to builda module for the 2.6.19 kernel unless you had the sourcesinstalled.

Actually there is not much to the file:

Code:
#ifndef _LINUX_CONFIG_H

#define _LINUX_CONFIG_H



#include <linux/autoconf.h>



#endif



So if you have problems you could probably just add to code here toyour 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 arefrom the devel package(unless you built it yourself)

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