chenjuchuan 发表于 2023-11-17 16:01:03

Ubuntu下交叉编译Go1.19.4遇到的问题

米尔开发板上没有Go运行环境,需要先编译GO环境源码,本次编译的是Go1.19.4版本,根据网上资料在编译如下步骤的时候出现问题:

mi@MI:/usr/local/go/src$ sudo GOROOT_BOOTSTRAP=/usr/local/go1.4CC_FOR_TARGET=aarch64-poky-linux-gcc CXX_FOR_TARGET=aarch64-poky-linux-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 ./make.bash

Building Go cmd/dist using /usr/local/go1.4. (go1.4-bootstrap-20170531 linux/amd64)
go tool dist: cannot invoke C compiler ["aarch64-poky-linux-gcc"]: exec: "aarch64-poky-linux-gcc": executable file not found in $PATH

Go needs a system C compiler for use with cgo.
To set a C compiler, set CC=the-compiler.
To disable cgo, set CGO_ENABLED=0.



不知道如何下手排查这个问题!!!

chenjuchuan 发表于 2023-11-17 16:02:21

aarch64-poky-linux-gcc等都已经设置完毕,并且没有问题

chenjuchuan 发表于 2023-11-20 07:22:31

本帖最后由 chenjuchuan 于 2023-11-20 08:47 编辑

已解决,是应为使用sudo的原因。但是又出现新问题:

GOROOT_BOOTSTRAP=/usr/local/go1.4CC_FOR_TARGET=aarch64-poky-linux-gcc CXX_FOR_TARGET=aarch64-poky-linux-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 ./make.bash
Building Go cmd/dist using /usr/local/go1.4. (go1.4-bootstrap-20170531 linux/amd64)
Building Go toolchain1 using /usr/local/go1.4.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for host, linux/amd64.
# runtime/cgo
aarch64-poky-linux-gcc: error: unrecognized command line option '-m64'
go tool dist: FAILED: /usr/local/go/pkg/tool/linux_amd64/go_bootstrap install std cmd: exit status 2

网络上针对此种问题是:
打开Makefile文件,在 makefile中查找所有的“-m64”,然后删除即可。

可Go源码编译目录下没有makefile文件呀?能否再指导一下

页: [1]
查看完整版本: Ubuntu下交叉编译Go1.19.4遇到的问题