usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of ‘yylloc‘; scripts/dtc/d

在编译linux内核时,编译报错

usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of 'yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status

解决方法 1:【此方法我没有走通】

edit the file ./linux-rtk/scripts/dtc/dtc-lexer-lex.c Find the line
‘YYLTYPE yylloc’ and change it to ‘extern YYLTYPE yylloc’

解决方法 2:【此方法可用】

因为gcc的版本比较高,与当前的ubuntu系统不兼容,所以需要降低gcc版本。我当时编译报错时,用的是gcc-11,需要将gcc版本降到gcc-9.

当前版本查询:
查看当前的gcc版本:gcc --version
查看当前的g++版本:g++ --version

gcc版本降级:
查看已安装的gcc版本: ls /usr/bin/gcc*
如果版本中没有9版本,则安装:sudo apt-get install gcc-9
将9版本的优先级提高: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100
【上面中的100,指的是优先级,不一定是100,也可以是其他值,数值越大,优先级越高】

  • 22
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

梅尔文

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值