Sid
Sid

Reputation: 71

GCC not found in %PATH%

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

Upvotes: 1

Views: 16974

Answers (1)

jrefior
jrefior

Reputation: 4421

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.

Upvotes: 1

Related Questions