【问题标题】:GCC unable to compile Go ProgramGCC 无法编译 Go 程序
【发布时间】:2017-10-25 06:59:21
【问题描述】:

我使用 2D 游戏库在 Go 中编写了一个非常简单的程序。

package main

import (
    "github.com/hajimehoshi/ebiten"
    "github.com/hajimehoshi/ebiten/ebitenutil"
)

const screenWidth, screenHeight = 320, 240

func update(screen *ebiten.Image) error {
    ebitenutil.DebugPrint(screen, "Game test")
    return nil;
}
func main() {
    if err := ebiten.Run(update, screenWidth, screenHeight, 2, "Test"); err != nil {
        panic(err)
    }
}

然而,这依赖于 GCC 来编译。运行时,系统会提示我以下消息:

# github.com/go-gl/glfw/v3.2/glfw
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
# github.com/go-gl/gl/v2.1/gl
cc1.exe: sorry, unimplemented: 64-bit mode not compiled in

我尝试下载 MinGW-w64 来解决问题,但没有成功。

我将如何解决这个问题?

【问题讨论】:

    标签: gcc go


    【解决方案1】:

    所以你的 C 编译器不支持 64 位编译。解决此问题的一种方法是构建 32 位模式。默认情况下,Go 将尝试为您所在的系统架构构建,但您可以通过在构建之前设置环境变量 GOARCH=386 来修改该行为。在 Windows 上,您可以在 cmd 中输入:

    set GOARCH=386
    go build
    

    您可以使用此内容创建一个简单的.bat 批处理脚本,并在您想要构建时运行它。

    请注意,64 位系统可以正常运行 32 位程序。这也是确保当您将.exe 提供给其他人时,它将在他们的系统上运行(不考虑其他依赖项)的好方法。

    如果您想升级您的 C 编译器而不是构建 64 位应用程序,请参阅 this SO thread,也许这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多