Centos7编译Golang报错:/usr/bin/ld: /tmp/go-link-xx0.o: unrecognized relocation (0x2a) in section `.text‘

在低版本centos7(我的是7.4)中运行goland编译时报错:

/usr/bin/ld: /tmp/go-link-038275771/000010.o: unrecognized relocation (0x2a) in section `.text'

报错具体如下:

[root@xxx ginlaravel]# go run main.go
# command-line-arguments
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-038275771/000010.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

原因:

ld的版本过低,需要升级一下。

在你的centos7终端运行:

yum install binutils

[root@xxx ~]# yum install binutils
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.25.1-32.base.el7_4.1 will be updated
---> Package binutils.x86_64 0:2.27-44.base.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package          Arch           Version                     Repository    Size
================================================================================
Updating:
 binutils         x86_64         2.27-44.base.el7            base         5.9 M

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 5.9 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
binutils-2.27-44.base.el7.x86_64.rpm                       | 5.9 MB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : binutils-2.27-44.base.el7.x86_64                             1/2
  Cleanup    : binutils-2.25.1-32.base.el7_4.1.x86_64                       2/2
  Verifying  : binutils-2.27-44.base.el7.x86_64                             1/2
  Verifying  : binutils-2.25.1-32.base.el7_4.1.x86_64                       2/2

Updated:
  binutils.x86_64 0:2.27-44.base.el7

Complete!

完美解决。

-

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值