嵌入式爱好者

查看: 1278|回复: 3

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

[复制链接]

7

主题

16

帖子

46

积分

i.MX6UL通行证

扫一扫,手机访问本帖
发表于 2023-11-17 16:11:51 | 显示全部楼层 |阅读模式
I.MX6开发板上没有Go运行环境,需要先编译GO环境源码,本次编译的是Go1.19.4版本,根据网上资料在编译如下步骤的时候出现问题:

forlinx@ubuntu:/usr/local/go/src$ sudo GOROOT_BOOTSTRAP=/usr/local/go1.4  CC_FOR_TARGET=arm-poky-linux-gnueabi-gcc CXX_FOR_TARGET=arm-poky-linux-gnueabi-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 ["arm-poky-linux-gnueabi-gcc"]: exec: "arm-poky-linux-gnueabi-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.



arm-poky-linux-gnueabi-gcc等编译器都已安装正常
不知道如何下手排查这个问题!!!
回复

使用道具 举报

2

主题

19

帖子

269

积分

RK3568通行证i.MX RT通行证AM62x资料下载

发表于 2023-11-18 15:03:36 | 显示全部楼层
交叉编译的时候不用sudo
install 的时候才需要

用sudo 后等于切换一个使用者
PATH里面没有 arm-poky-linux- 的路径了

或是指定 CC_FOR_TARGET & CXX_FOR_TARGET 带上路径
CC_FOR_TARGET=<full_path>/arm-poky-linux-gnueabi-gcc CXX_FOR_TARGET=<full_path>/arm-poky-linux-gnueabi-g++
点评回复 支持 反对

使用道具 举报

7

主题

16

帖子

46

积分

i.MX6UL通行证

 楼主| 发表于 2023-11-19 22:21:36 | 显示全部楼层
感谢,的确是这样原因。不过又出现新的问题了:

GOROOT_BOOTSTRAP=/usr/local/go1.4  CC_FOR_TARGET=arm-poky-linux-gnueabi-gcc CXX_FOR_TARGET=arm-poky-linux-gnueabi-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
arm-poky-linux-gnueabi-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文件呀?能否再指导一下

点评回复 支持 反对

使用道具 举报

2

主题

19

帖子

269

积分

RK3568通行证i.MX RT通行证AM62x资料下载

发表于 2023-11-20 11:59:07 | 显示全部楼层
试试下面指令

find . -type f -exec grep -nH -e "\-m64" {} \;
点评回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-4-28 22:11

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

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