dongzhun6952 2018-02-04 07:09
浏览 591

在%PATH%中找不到GCC

I am trying to run this code:

package main

import ("github.com/faiface/pixel"
        "github.com/faiface/pixel/pixelgl")

func run(){
    cfg := pixelgl.WindowConfig{
        Title:"My First program",
        Bounds:pixelgl.R(0,0,800,600)
    }
    window,err := pixelgl.NewWindow(cfg)
    if err != nil{
        panic(err)
    }
    for !window.Closed(){
        win.Update()
    }
}       


func main(){
    pixelgl.Run(run)
}

but whenever I type

go run pixel.go

I get this error

exec: "gcc": executable file not found in %PATH%

I have C:\TDM-GCC-64\bin in both my user path and the system path and the system finds gcc easily whenever I type "gcc" into cmd. I have an x64 Windows 10 System

  • 写回答

1条回答 默认 最新

  • douhan8892 2018-02-04 07:43
    关注

    You're depending on cgo packages, so you'll need GCC. I can't find a version of TDM-GCC that's been updated since 2015. I suggest looking for an alternative MinGW-w64 installation that has been updated more recently, such as this one which I have recently used for OpenGL with Go (1.9.1) on Windows 10 x64:

    http://mingw-w64.org/doku.php

    You'll need to add the installed directory /bin to your path, as you did for TDM-GCC-64. You can test by trying g++ in PowerShell (or cmd) to see whether it's a known command. You should be able to go get packages you need from PowerShell.

    If you're still having trouble, make sure you have a relatively recent version of Go installed.

    Also, it's always recommended to use go build and then run the executable it creates instead of go run for any non-trivial code. If you haven't run any other Go code yet, you could also try a hello world to make sure there aren't any problems with your Go installation and setup.

    The GLFW installation docs talk about generating build files with cmake, but I don't think you'll need to do that.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作