在低版本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!
完美解决。
-