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条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!