一、问题描述

在写好驱动程序要编译的时候,出现以下错误提示(中间也有很多类似头文件和定义缺失的提示,篇幅问题没有放上来):

make -C /home/lzh/study_1/alientek-alpha/kernel-alientek M=/home/lzh/study_1/study_drivers/1_chardevbase modules
make[1]: Entering directory '/home/lzh/study_1/alientek-alpha/kernel-alientek'CC [M]  /home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.o
In file included from ./arch/x86/include/asm/bitops.h:16:0,from include/linux/bitops.h:36,from include/linux/kernel.h:10,from /home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.c:2:
./arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’:
./arch/x86/include/asm/arch_hweight.h:53:42: error: expected ‘:’ or ‘)’ before ‘POPCNT64’asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)^
./arch/x86/include/asm/alternative.h:125:28: note: in definition of macro ‘ALTINSTR_REPLACEMENT’b_replacement(num)":\n\t" newinstr "\n" e_replacement(num) ":\n\t"^
./arch/x86/include/asm/arch_hweight.h:53:7: note: in expansion of macro ‘ALTERNATIVE’asm (ALTERNATIVE("call __sw_hweight64", POPCNT64, X86_FEATURE_POPCNT)^
In file included from ./arch/x86/include/asm/pgtable_types.h:250:0,from ./arch/x86/include/asm/processor.h:18,from ./arch/x86/include/asm/thread_info.h:49,from include/linux/thread_info.h:54,from ./arch/x86/include/asm/preempt.h:6,from include/linux/preempt.h:18,from include/linux/spinlock.h:50,from include/linux/seqlock.h:35,from include/linux/time.h:5,from include/uapi/linux/timex.h:56,from include/linux/timex.h:56,from include/linux/sched.h:19,from include/linux/blkdev.h:4,from include/linux/ide.h:12,from /home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.c:4:
include/asm-generic/pgtable-nopud.h: At top level:
include/asm-generic/pgtable-nopud.h:15:0: warning: "PUD_SHIFT" redefined#define PUD_SHIFT PGDIR_SHIFT^
In file included from ./arch/x86/include/asm/pgtable_types.h:205:0,from ./arch/x86/include/asm/processor.h:18,from ./arch/x86/include/asm/thread_info.h:49,from include/linux/thread_info.h:54,from ./arch/x86/include/asm/preempt.h:6,from include/linux/preempt.h:18,from include/linux/spinlock.h:50,from include/linux/seqlock.h:35,from include/linux/time.h:5,from include/uapi/linux/timex.h:56,from include/linux/timex.h:56,from include/linux/sched.h:19,from include/linux/blkdev.h:4,from include/linux/ide.h:12,from /home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.c:4:
./arch/x86/include/asm/pgtable_64_types.h:33:0: note: this is the location of the previous definition#define PUD_SHIFT 30^^
In file included from include/linux/sched.h:32:0,from include/linux/blkdev.h:4,from include/linux/ide.h:12,from /home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.c:4:
include/linux/cputime.h:4:25: fatal error: asm/cputime.h: 没有那个文件或目录
compilation terminated.
scripts/Makefile.build:264: recipe for target '/home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.o' failed
make[2]: *** [/home/lzh/study_1/study_drivers/1_chardevbase/chardevbase.o] Error 1
Makefile:1384: recipe for target '_module_/home/lzh/study_1/study_drivers/1_chardevbase' failed
make[1]: *** [_module_/home/lzh/study_1/study_drivers/1_chardevbase] Error 2
make[1]: Leaving directory '/home/lzh/study_1/alientek-alpha/kernel-alientek'
Makefile:9: recipe for target 'kernel_modules' failed
make: *** [kernel_modules] Error 2
lzh@ubuntu16:~/study_1/study_drivers/1_chardevbase$ make
make -C /home/lzh/study_1/alientek-alpha/kernel-alientek M=/home/lzh/study_1/study_drivers/1_chardevbase modules
make[1]: Entering directory '/home/lzh/study_1/alientek-alpha/kernel-alientek'
Makefile:610: arch//Makefile: 没有那个文件或目录
make[1]: *** No rule to make target 'arch//Makefile'。 停止。
make[1]: Leaving directory '/home/lzh/study_1/alientek-alpha/kernel-alientek'
Makefile:9: recipe for target 'kernel_modules' failed
make: *** [kernel_modules] Error 2

但是我的Makefile文件十分简单,应该没有什么问题:

KERNELDIR :=/home/lzh/study_1/alientek-alpha/kernel-alientek
CURRENT_PATH := $(shell pwd)
ENV:=ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
obj-m :=chardevbase.obuild :kernel_moduleskernel_modules:$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) modules
clean:$(MAKE) -C $(KERNELDIR) M=$(CURRENT_PATH) clean

二、问题解决

找到用于编译驱动模块的linux源码,进入它的Makefile文件,进行如下修改:

在大概255行的地方:

将:

ARCH         ?= $(SUBARCH)
CROSS_COMPILE   ?= $(CONFIG_CROSS_COMPILE:"%"=%)

改为:

ARCH     ?= arm
CROSS_COMPILE   ?= arm-linux-gnueabihf-

注意:

1、这边重新定义的值是没有括号的了。

2、由于我用的是arm-linux-gnueabihf这个交叉编译器,所以这里修改为它,使用其他编译器的话记得进行对应修改。

编译linux驱动时提示很多源码头文件和定义缺失相关推荐

  1. linux源码头文件_您必须在2020年尝试的十大最佳Linux码头

    linux源码头文件 Who says Linux cannot be beautiful? Today we'll be going over the top 10 best Linux docks ...

  2. oracle10 64位odbc,图文教你64位win10添加oracle odbc驱动时提示无法加载oracle如何解决...

    现在电脑已成为我们工作生活的一部分,相信大家在操作电脑时一定会遇到这样那样的问题,64位win10添加oracle odbc驱动时提示无法加载oracle如何解决这个问题就是我们经常会遇到的,这样的问 ...

  3. Linux 编译时查找错误字符,编译Linux内核时出现“fatal error: linux/netfilter/xt_dscp: No such file or directory”...

    编译Linux内核时出现"fatal error: linux/netfilter/xt_dscp: No such file or directory".下面开始查找原因. 第一 ...

  4. Mac上编译Linux内核时找不到ncurses

    Mac上编译Linux内核时找不到ncurses 前言 Linux源码零零散散看了一些,东西太多.今天突然有兴趣想去编译一下Linux内核,就去网上找了一些资料,由于我是用的Mac,然后并没有找到好的 ...

  5. scp连接linux网络错误,winscp连接linux(centos7)时提示主机超过15秒无通信,继续等待的解决方法...

    1. 前言 本文主要讲解winscp连接linux(centos7)时提示主机超过15秒无通信,继续等待的解决方法 2. winscp报错界面 winscp报错界面如下: 解决方法如下: 3. 确保网 ...

  6. Dev C++可以编译但运行时提示Failed to execute且Error 0:操作成功完成。

    Dev C++可以编译但运行时提示Failed to execute且Error 0:操作成功完成. 问题 代码 现象 解决办法 更换GCC 可能和杀毒用软件有关系 问题 今天来复习C语言,写了简单几 ...

  7. 新win7系统死机,打开驱动精灵就卡住,解决方案 安装戴尔DELL Optilex 7040 USB驱动时提示无法定位程序输入点 kernel32.dll,解决方案

    新win7系统死机,打开驱动精灵就卡住,解决方案 安装戴尔DELL Optilex 7040 USB驱动时提示无法定位程序输入点 kernel32.dll,解决方案 原因: 新系统打卡驱动精灵卡死其实 ...

  8. 惠普打印机介质不匹配_HP打印机安装驱动时提示“重要!选择与打印机的连接方式”解决方法...

    HP双面激光打印机400系列在插上USB打印数据线连接到电脑安装驱动的过程中提示"重要!选择与打印机的连接方式",从而导致无法正常安装对应的hp打印机驱动程序,这应该是非常头疼的事 ...

  9. 淮安掼蛋网页版-源码头文件总结

     原文: 淮安掼蛋网页版-源码头文件总结 客户端程序很多时候都可以做出网页版的(WEB版),以下是项目之我是掼蛋王头文件-总结. A,写好每个类的头文件后,要进行分类,比如:网页版掼蛋,写上Sou ...

最新文章

  1. 15分钟带你入门sklearn与机器学习——分类算法篇
  2. Android Zxing 加入闪光灯功能
  3. 迅雷2012校园招聘笔试题
  4. python输出字符串的后两位_Python字符串三种格式化输出
  5. gRPC-go源码(2):ClientConn
  6. This is the default error page for nginx that is distributed with EPEL.
  7. 敏捷开发“松结对编程”实践之二:计划与设计篇(大型研发团队,学习型团队,139团队,师徒制度,设计评审,预想陈述,共同估算,扑克牌估算)...
  8. 5.Linux性能诊断 --- 追踪技术
  9. python创建列表副本的方法_Python之列表方法
  10. SpaceClaim功能解析与应用介绍
  11. TUIO协议 (转)
  12. 如何同步企业微信的标签?
  13. Python批量化实现SAR图像的海陆分割
  14. 全新三维成像技术:我们离科幻故事里的立体投影又近了一步
  15. Python 追加 Excel 数据
  16. vue中缓存当前路由的实现
  17. Swift编程语言简介
  18. linux主ip地址 网络信息不可用,win10 安装虚拟机提示 主IP地址显示网络信息不可用...
  19. CodeForces 13A Numbers
  20. python编程之旅 random随机库 第一课 制作简单的随机数程序

热门文章

  1. vue 导出excel,合并单元格,修改样式
  2. 石油大学网考 在线作业、在线考试 自动答题辅助工具
  3. Java String对象的经典问题(new String())
  4. 2022年京东双十一iPhone14pro会降价吗?
  5. Python授权码生成器(密码生成器)
  6. Android Studio 开发
  7. Linux NVMe Driver学习笔记之8:IO SQ/CQ的创建过程
  8. linux can总线接收数据串口打包上传_SPI、I2C、UART、I2S、GPIO、SDIO、CAN,你能分清楚吗?...
  9. usb驱动的基本结构和函数简介【转】
  10. 半年时间,拍摄8省市10个案例,我们见到了这样的智能中国