天嵌 ARM开发社区

 找回密码
 注册
查看: 4947|回复: 5

编译出现:no such file or directory!

[复制链接]
zhiyuan1986 发表于 2012-1-12 16:02:16 | 显示全部楼层 |阅读模式
大家好,我用天嵌2440板子,编译一个驱动模块,总是找不到头文件。不知道该如何处理。请务必帮忙。高手能留下QQ指点一下最好了。程序如下,执行make就出错。找不到头文件。
/****************hellomod.c*******************************/
#include <linux/module.h> //所有模块都需要的头文件
#include <linux/init.h> // init&exit相关宏
MODULE_LICENSE("GPL");
static int __init hello_init (void)
{
    printk("Hello china init/n");
    return 0;
}

static void __exit hello_exit (void)
{
    printk("Hello china exit/n");
}

module_init(hello_init);
module_exit(hello_exit);

/****************hellomod.c*******************************/

/****************Makefile*******************************/

KDIR := /opt/EmbedSky/linux-2.6.30.4

obj-m := hellomode.o

all:
        make -C $(KDIR) M=$(PWD) modules ARCH=arm CROSS_COMPILE=arm-linux-
clean:
        rm -f *.ko *.o *.mod.o *.mod.c *.symvers modul*
/****************Makefile*******************************/
[root@localhost root]# cd ..
提示信息如下:
[root@localhost /]# cd opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/
[root@localhost hellomode]# make
make -C /opt/EmbedSky/linux-2.6.30.4 M=/opt/EmbedSky/linux-2.6.30.4/drivers/hell
omode modules ARCH=arm CROSS_COMPILE=arm-linux-
make[1]: Entering directory `/opt/EmbedSky/linux-2.6.30.4'

  WARNING: Symbol version dump /opt/EmbedSky/linux-2.6.30.4/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.o
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:1:26: error: linux/mo
dule.h: No such file or directory
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:2:24: error: linux/in
it.h: No such file or directory
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:3: error: expected de
claration specifiers or '...' before string constant
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:3: warning: data defi
nition has no type or storage class
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:3: warning: type defa
ults to 'int' in declaration of 'MODULE_LICENSE'
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:3: warning: function
declaration isn't a prototype
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:4: error: expected '=
', ',', ';', 'asm' or '__attribute__' before 'hello_init'
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:9: error: expected '=
', ',', ';', 'asm' or '__attribute__' before 'hello_exit'
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:14: warning: data def
inition has no type or storage class
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:14: warning: type def
aults to 'int' in declaration of 'module_init'
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:14: warning: paramete
r names (without types) in function declaration
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:15: warning: data def
inition has no type or storage class
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:15: warning: type def
aults to 'int' in declaration of 'module_exit'
/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.c:15: warning: paramete
r names (without types) in function declaration
make[2]: *** [/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode/hellomode.o] Error
1
make[1]: *** [_module_/opt/EmbedSky/linux-2.6.30.4/drivers/hellomode] Error 2
make[1]: Leaving directory `/opt/EmbedSky/linux-2.6.30.4'
make: *** [all] Error 2
[root@localhost hellomode]#
raominping 发表于 2012-1-12 18:50:08 | 显示全部楼层
这个.不清楚哦..
TQ-ZQL 发表于 2012-1-13 11:23:25 | 显示全部楼层
确定找不到什么不妥的地方(除了换行写错了),你可以尝试下在其它目录下建立一个新的工程,将Kdir指定到你当前PC用的Linux内核目录下(当然你的Makefile中arch那些也是要去掉的),再去测试一下。
(一般这种情况可能会是内核路径指定不对)
orvly 发表于 2012-1-14 00:41:06 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
cyd411 发表于 2012-1-16 11:57:30 | 显示全部楼层
KDIR := /opt/EmbedSky/linux-2.6.30.4    这里对吗?应该有bin吗?

我也是新手
亚瑟王 发表于 2012-1-16 17:14:09 | 显示全部楼层
亲,
1、编译驱动模块之前,必须先完整编译一遍内核源码,否则很多依赖文件是找不到的。
2、驱动模块不需要放到内核的目录下,如果放到内核目录下,建议你用天嵌科技提供的Linux移植教程里面的方法来做。
你的问题的原因在于:根据你提供的操作信息,分析得出:你的内核是放到/root/opt/EmbedSky目录下的,而你在Makefile里面指定的却是/opt/EmbedSky目录,也就是说,Makefile找不到内核。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-9-30 07:23 , Processed in 1.037149 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

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