1

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

3
  • 1
    Have you tried running a simple Go "hello world" on your system to make sure there's no problem with your Go setup/installation? tour.golang.org/welcome/1 Commented Feb 4, 2018 at 7:17
  • It's also recommended to build instead of run for any non-trivial program; you could try build and then execute and confirm that you get the same error, and tell us whether the error occurs when you build or when you execute. go build pixel.go Commented Feb 4, 2018 at 7:24
  • Have you tried to run gcc manually in the same console as go? Commented Feb 4, 2018 at 8:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.