douba2705 2014-04-29 23:49
浏览 366
已采纳

如何在Mac上针对Ubuntu交叉编译Go程序?

vagrant@precise64:/vagrant$ sudo ./myprogram 
./myprogram: 1: ./myprogram: Syntax error: "(" unexpected

I found out this happens when I do not generate the binary file from the same OS. I do go build with Mac OS but I need to run this binary from Vagrant that uses Ubuntu Linux. What command should I use instead of go build from Mac so that I can run the binary program in Vagrant environment?

  • 写回答

2条回答 默认 最新

  • doutui839638 2014-04-30 00:06
    关注

    You need to set up a cross-compilation environment (by building the go compiler yourself). Dave Cheney's blog has good instructions: http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?