当前位置: 首页 > news >正文

【已解决】编译Linux内核报错multiple definition of yylloc

问题描述

在学习正点原子的驱动开发指南过程中,在编译Linux内核时出现以下报错,内核文件为:linux-imx-rel_imx_4.1.15_2.1.0_ga。

./mx6ull_alientek_emmc.sh文件内容如下

#!/bin/sh
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- imx_v7_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all -j16

 报错信息如下:

In file included from include/linux/kernel.h:11,from include/asm-generic/bug.h:13,from ./arch/arm/include/asm/bug.h:61,from include/linux/bug.h:4,from include/linux/page-flags.h:9,from kernel/bounds.c:9:
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes]22 | int ____ilog2_NaN(void);| ^~~CHK     include/generated/bounds.hUPD     include/generated/bounds.hCC      arch/arm/kernel/asm-offsets.s
In file included from include/linux/kernel.h:11,from include/linux/sched.h:17,from arch/arm/kernel/asm-offsets.c:14:
include/linux/log2.h:22:1: warning: ignoring attribute ‘noreturn’ because it conflicts with attribute ‘const’ [-Wattributes]22 | int ____ilog2_NaN(void);| ^~~CHK     include/generated/asm-offsets.hUPD     include/generated/asm-offsets.hCALL    scripts/checksyscalls.shHOSTLD  scripts/dtc/dtc
/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x50): multiple definition of yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:100:scripts/dtc/dtc] 错误 1
make[1]: *** [scripts/Makefile.build:403:scripts/dtc] 错误 2
make[1]: *** 正在等待未完成的任务....HOSTLD  scripts/genksyms/genksymsHOSTLD  scripts/mod/modpost
make: *** [Makefile:556:scripts] 错误 2
make: *** 正在等待未完成的任务....
txj@txj-virtual-machine:~/IMX6ULL/linux_core/linux-imx-rel_imx_4.1.15_2.1.0_ga$

解决方案

先后尝试过将gcc-12版本重装为gcc-9版本,运行后出现更多错误。以及在/scripts/dtc/dtc-lexer.lex.c文件中对YYLTYPE yylloc; + extern 变为extern YYLTYPE yylloc; 无效。

最后通过以下办法解决问题:

重新下载了arm-linux-gnueabihf-gcc

gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar 

通过百度网盘分享的文件:gcc-linaro-4.9.4-2017.01-x86_64_arm...
链接:https://pan.baidu.com/s/1tdF7qalld4E86S3kc9-dAQ?pwd=us5v 
提取码:us5v 
--来自百度网盘超级会员V5的分享

步骤如下:

将文件拷贝到Ubuntu根目录下的tools文件中
sudo mkdir /usr/local/arm
sudo cp gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz /usr/local/arm/ -f
sudo tar -vxf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz
sudo vi /etc/profile
export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin
sudo apt-get install lsb-core lib32stdc++6
sudo reboot
arm-linux-gnueabihf-gcc -v

 gcc版本为下图,为安装成功。

 这个时候再运行一次./mx6ull_alientek_emmc.sh 应该就能够正常编译了。

如果gcc版本还是原来的,需要先删除先前的 arm-linux-gnueabihf-gcc再重新进行上面的步骤。

which arm-linux-gnueabihf-gcc-<version>,找到文件的路径,备份一下,然后删除它即可。


http://www.mrgr.cn/news/59044.html

相关文章:

  • 嵌入式学习-网络-Day01
  • 题解:P2942 [USACO09MAR] Moon Mooing G
  • 《a16z : 2024 年加密货币现状报告》解析
  • 由于导出的数据名字中带有/,导致Matlab打不开,怎么办?
  • 异次元v4.0
  • 渗透测试导学
  • 大模型训练、微调数据集
  • linux网络编程6——基于UDP的可靠传输协议KCP/QUIC
  • Minio文件服务器:安装
  • [LeetCode] 77. 组合
  • shodan1,shodan简介和kali下的使用
  • 【Linux】线程池详解及其基本架构与单例模式实现
  • [LeetCode] 494. 目标和
  • 【动态规划】【简单多状态dp问题】买卖股票相关问题(冷冻期、手续费、限制次数)
  • 基于SSM农业信息管理系统的设计
  • python曲线拟合通用代码
  • 数据结构(java)——数组的构建和插入
  • 【网络安全】一文讲清Zero Trust(零信任)安全
  • 【Python爬虫+数据分析】详细教学知网文献基本信息爬取方式(附详细教程+完整代码)
  • ctfshow的sql注入解题思路171-211
  • 文言编程:古老文字与现代编程的融合
  • 禾川SV-X2E A伺服驱动器参数设置——脉冲型
  • Gateway 统一网关
  • 【论文阅读】ESRGAN
  • C++ string类常用接口总结
  • 「C/C++」C++17 之 std::filesystem::directory_entry 文件系统目录条目