设为首页收藏本站
查看: 406|回复: 2

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

[复制链接]

3

主题

2

回帖

27

积分

新手上路

积分
27
chenjuchuan 发表于 2023-11-17 16:01:03 | 显示全部楼层 |阅读模式
米尔开发板上没有Go运行环境,需要先编译GO环境源码,本次编译的是Go1.19.4版本,根据网上资料在编译如下步骤的时候出现问题:

mi@MI:/usr/local/go/src$ sudo GOROOT_BOOTSTRAP=/usr/local/go1.4  CC_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.



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

回复

使用道具 举报

3

主题

2

回帖

27

积分

新手上路

积分
27
 楼主| chenjuchuan 发表于 2023-11-17 16:02:21 | 显示全部楼层
aarch64-poky-linux-gcc等都已经设置完毕,并且没有问题
回复 支持 反对

使用道具 举报

3

主题

2

回帖

27

积分

新手上路

积分
27
 楼主| chenjuchuan 发表于 2023-11-20 07:22:31 | 显示全部楼层
本帖最后由 chenjuchuan 于 2023-11-20 08:47 编辑

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

GOROOT_BOOTSTRAP=/usr/local/go1.4  CC_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文件呀?能否再指导一下

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录

本版积分规则

Archiver|手机版|小黑屋|米尔科技论坛   

GMT+8, 2024-5-3 15:28 , Processed in 0.044452 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表