慢行者
分类: linux
2013-03-19 16:51:14
编译.ko驱动模块过程报如下错误:
$ make
信息1:
arch=arm cross_compile=/opt/freescale/usr/local/gcc-4.4.4-glibc-2.11.1-multilib-1.0/arm-fsl-linux-gnueabi/bin/arm-fsl-linux-gnueabi- make -c /home/thy/ltib/rpm/build/linux m=/mnt/hgfs/share/work/fs_lradc modules
make[1]: entering directory `/home/thy/ltib/rpm/build/linux-2.6.35.3'
cc [m] /mnt/hgfs/share/work/fs_lradc/fs_lradc.o
/mnt/hgfs/share/work/fs_lradc/fs_lradc.c: in function 'lradc0_read':
/mnt/hgfs/share/work/fs_lradc/fs_lradc.c:136: error: implicit declaration of function 'copy_to_user'
make[2]: *** [/mnt/hgfs/share/work/fs_lradc/fs_lradc.o] error 1
make[1]: *** [_module_/mnt/hgfs/share/work/fs_lradc] error 2
make[1]: leaving directory `/home/thy/ltib/rpm/build/linux-2.6.35.3'
make: *** [modules] error 2
信息2:
cpld_lcmxo2-2000hc.c:125: error: implicit declaration of function 'mkdev'
cpld_lcmxo2-2000hc.c:128: error: implicit declaration of function 'register_chrdev_region'
cpld_lcmxo2-2000hc.c:135: error: implicit declaration of function 'alloc_chrdev_region'
cpld_lcmxo2-2000hc.c:141: error: implicit declaration of function 'unregister_chrdev_region'
解决办法:
添加
#include
#include
#include
出现类似于“implicit declaration of function ***”这种错误,多半是由于没有正确添加头文件造成的。