本文共 435 字,大约阅读时间需要 1 分钟。
在go语言中用到了cgo的程序,在编译的时候,遇到了如下错误:
# command-line-arguments
/home/compile/makepkg_go/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 /usr/bin/ld: cannot find -lCImageUtil collect2: 错误:ld 返回 1使用go version名称查看go版本时,发现版本不对。
在编译文件中加入
if [[ -d /home/compile/makepkg_go/go1.9 ]]; then
export GOROOT=/home/compile/makepkg_go/go1.9 fi export PATH=$GOROOT/bin:$PATH将所用到的go版本包含进来。则错误消失
或
如果没有用到cgo,可以使用export CGO_ENABLED=1命令将cgo关掉
转载地址:http://onown.baihongyu.com/