chenjuchuan 发表于 2023-11-17 16:11:51

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

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

forlinx@ubuntu:/usr/local/go/src$ sudo GOROOT_BOOTSTRAP=/usr/local/go1.4CC_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等编译器都已安装正常
不知道如何下手排查这个问题!!!

kunyi 发表于 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++

chenjuchuan 发表于 2023-11-19 22:21:36

感谢,的确是这样原因。不过又出现新的问题了:

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

kunyi 发表于 2023-11-20 11:59:07

试试下面指令

find . -type f -exec grep -nH -e "\-m64" {} \;
页: [1]
查看完整版本: Ubuntu下交叉编译Go1.19.4遇到的问题