栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

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

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

在低版本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!

完美解决。

-

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/908445.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号