GCC无法编译Go程序

GCC无法编译Go程序

本文介绍了GCC无法编译Go程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 包主
$ b在Go中使用2D游戏库编写了一个非常简单的程序。 $ b导入(
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)
}
}





 #github.com/go-gl/glfw/v3.2/ glfw 
cc1.exe:对不起,未实现:未在
中编译的64位模式github.com/go-gl/gl/v2.1/gl
cc1.exe:对不起,未实现:64位模式未编译

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



我该如何解决这个问题?

解决方案

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

  set GOARCH = 386 
go build

code>

您可以使用此内容创建一个简单的 .bat 批处理脚本,并运行当你想建立。



请注意,64位系统将运行32位程序就好了。这也是一个很好的方法,可以确保当你将 .exe 给别人时,它会在他们的系统上运行(不考虑其他依赖)。



如果要升级C编译器而不是构建64位应用程序,请参阅,也许有帮助。


I wrote a very simple program in Go using using a 2D game library.

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

This, however, relies on GCC to compile. When running, I'm prompted with this message:

# 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

I attempted to download MinGW-w64 to rectify the issue, but it hasn't been successful.

How would I go about resolving this?

解决方案

So your C compiler does not support 64 bit compilation. One way to resolve this is to build in 32 bit mode. Go will by default try to build for the system architecture that you are on but you can modify that behavior by setting the environment variable GOARCH=386 before building. On Windows you can type this into your cmd:

set GOARCH=386
go build

You could create a simple .bat batch script with this content and run that when you want to build.

Note that 64 bit systems will run 32 bit programs just fine. This is also a nice way to make sure that when you give the .exe to someone else, it will run on their system (not considering other dependencies).

If you want to upgrade your C compiler instead to build 64 bit applications, see this SO thread, maybe that helps.

这篇关于GCC无法编译Go程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 00:28