golang 1.6 交叉编译

huangapple go评论75阅读模式
英文:

golang 1.6 cross compile

问题

在golang 1.6中,当我从64位架构交叉编译到32位Linux时,go install命令会将可执行文件放在bin/linux_386/<exe>中。

有没有办法将它放在bin/中呢?如果我在32位环境中构建,那么它将放在bin/中。我希望无论是在沙盒外交叉编译到32位还是在32位沙盒内本地编译,可执行文件都能放在相同的位置。

我目前的解决方法是将linux_386目录软链接到.,即ln -s . linux_386

英文:

In golang 1.6, when I cross compile from my 64-bit arch to 32-bit for Linux, the go install command puts the executable in bin/linux_386/&lt;exe&gt;.

Is there a way to put it into bin/ instead? If I build in the 32-bit environment, then it will go in bin/. I want the exe to go into the same location regardless of if I cross compile to 32-bit outside the sandbox, or natively compile inside the 32-bit sandbox.

My workaround right now is to soft link the linux_386 dir to ., as in ln -s . linux_386.

答案1

得分: 1

你可以使用"go build"命令手动进行安装,无法使用"go install"命令进行安装:

 go build -o $GOPATH/bin/<exe> $GOPATH/src/your/<pkg>
英文:

You can't with go install, however you can do it manually:

 go build -o $GOPATH/bin/&lt;exe&gt; $GOPATH/src/your/&lt;pkg&gt;

huangapple
  • 本文由 发表于 2016年3月30日 05:20:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/36295294.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定