Today I decided I want to continue learning the programming language Go and write a small OpenGL program with it. For OpenGL I wanted to use the Go package “github.com/go-gl/gl” which usually can be installed with “go get github.com/go-gl/gl”. This, however, resulted in a bunch of undefined reference errors, because you need to install GLEW beforehand. That on the other hand is not so easy on Windows. While you can download MSVC-compatible .lib files of GLEW and MinGW32 hypothetically can use them, they won’t work for building the gl package (results in other undefined references in the likes of _imp____glew*). Instead, you need to build MinGW32 library files (.a).
Took me some time to figure it out, but these were roughly the steps it required, assuming that Go is already installed:
1. Install MinGW32 and the package mingw32-base
2. Download GLEW source code from http://glew.sourceforge.net/
3. Get the build script from http://stackoverflow.com/questions/6005076/building-glew-on-windows-with-mingw/6005262#6005262
4. Copy the build script into the GLEW source folder and execute it, this will build the library files
5. Copy the static library files (lib/libglew32.a etc.) into your MinGW32 lib folder (e.g. C:\MingW32\lib)
6. Copy the header files (include/GL/glew32.h etc.) into the MingW32 include folder (e.g. C:\MingW32\include\GL)
7. Copy lib/glew32.dll into Windows’ system32 folder
8. go get github.com/go-gl/gl
After this you should be able to use the gl package.