doushouxie7064 2013-05-14 20:59
浏览 55
已采纳

在64位系统上编译32位二进制文​​件

I've coded a Go program in a 64 bit system but I want to compile a 32 bit binary!

The 64 bit binary is working just great but I have no idea how to create a 32 bit binary.

How can I do it?

  • 写回答

3条回答 默认 最新

  • douqianke7467 2013-05-14 23:55
    关注

    If you built your Go from source, then you can build any additional compilers and libraries for any CPU and OS. If you are on windows/amd64 and want to build for windows/386, then this will build everything you need to compile for windows/386:

    set GOARCH=386  
    cd %GOROOT%\src  
    make.bat --no-clean  
    

    Once you have done that, you can build your windows/386 executable with:

    set GOARCH=386  
    cd %YOUR_PROG_DIR%  
    go build  
    

    Since you are on windows/amd64, you should be able to even run / test your windows/386 programs too. Just make sure to set GOARCH=386 before you invoke any commands for windows/386.

    One caveat: this does not support cgo, so you cannot use any packages that use cgo.

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

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch