[problem help] go语言项目编译错误
Tofloor
poster avatar
老马
deepin
2024-08-17 09:11
Author

windows10下编译正常的程序,在deepin V23下报错,请问是缺少什么软件或库,要如何安装?

报错信息如下:

go build

xdlerp

/soft/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/gcc -m64 -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Wl,--compress-debug-sections=zlib /tmp/go-link-474912881/go.o /tmp/go-link-474912881/000000.o /tmp/go-link-474912881/000001.o /tmp/go-link-474912881/000002.o /tmp/go-link-474912881/000003.o /tmp/go-link-474912881/000004.o /tmp/go-link-474912881/000005.o /tmp/go-link-474912881/000006.o /tmp/go-link-474912881/000007.o /tmp/go-link-474912881/000008.o /tmp/go-link-474912881/000009.o /tmp/go-link-474912881/000010.o /tmp/go-link-474912881/000011.o /tmp/go-link-474912881/000012.o /tmp/go-link-474912881/000013.o /tmp/go-link-474912881/000014.o /tmp/go-link-474912881/000015.o /tmp/go-link-474912881/000016.o /tmp/go-link-474912881/000017.o /tmp/go-link-474912881/000018.o /tmp/go-link-474912881/000019.o /tmp/go-link-474912881/000020.o -O2 -g -lresolv -O2 -g -lpthread -no-pie
/usr/bin/ld: i386 architecture of input file `/tmp/go-link-474912881/000000.o' is incompatible with i386:x86-64 output
/usr/bin/ld: warning: /tmp/go-link-474912881/000000.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
collect2: error: ld returned 1 exit status

Reply Favorite View the author
All Replies
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-08-17 10:04
#1

/usr/bin/ld: i386 architecture of input file `/tmp/go-link-474912881/000000.o' is incompatible with i386:x86-64 output

deepin貌似已经没有32位库的支持了

运行  go env  命令检查 下 GOARCH  的值

看看是不是amd64

Reply View the author
raspbian
deepin
2024-08-17 10:10
#2

你要交叉编译?

deepinv23没有32位的ld

Reply View the author
老马
deepin
2024-08-17 11:00
#3
把一切操作变成GUI

/usr/bin/ld: i386 architecture of input file `/tmp/go-link-474912881/000000.o' is incompatible with i386:x86-64 output

deepin貌似已经没有32位库的支持了

运行  go env  命令检查 下 GOARCH  的值

看看是不是amd64

对的

GOARCH='amd64'

Reply View the author
raspbian
deepin
2024-08-17 11:04
#4

cgo打开了吗?

Reply View the author
老马
deepin
2024-08-17 11:16
#5
raspbian

cgo打开了吗?

CGO_ENABLED='1'

Reply View the author
老马
deepin
2024-08-17 11:17
#6
raspbian

你要交叉编译?

deepinv23没有32位的ld

有用到 modernc.org/sqlite v1.23.1

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-08-17 11:19
#7
老马

对的

GOARCH='amd64'

你调用了什么依赖库? clean一下缓存,

 

go mod tidy
go list -m all

 检查一下依赖

 

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-08-17 11:20
#8

你的源码有没有放在ext文件系统的分区,千万不要放在NTFS

Reply View the author
raspbian
deepin
2024-08-17 11:36
#9
It has been deleted!
老马
deepin
2024-08-17 18:49
#10

最终通过各种排除,发现是windows下生成的资源文件resource.syso不兼容引起的,将该文件改名后go build顺利通过,感谢大家的帮助!

Reply View the author