GLEW for MinGW in Windows

For some reason I had a tough time building the GLEW (OpenGL Extension Wrangler Library – as of this writing the most recent version is 1.10.0). I needed it to pair up with SFML and I wanted to use MinGW’s compiler, and for some reason, the developers of GLEW only provided the pre-compiled libraries for VC++.

I stumbled upon this stackoverflow post, which… didn’t work for me by just copy pasting the whole thing to my command prompt ): . So this is what I did to get it working (assuming you have MinGW’s bin directory in your environment paths).

cd to the root directory and execute these line by line:

mkdir lib
gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude  -DGLEW_BUILD -o src/glew.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a    -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

ar cr lib/libglew32.a src/glew.o

gcc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude  -DGLEW_BUILD -o src/ -c src/glew.c
gcc -shared -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/ -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32

ar cr lib/libglew32mx.a src/

You should find the *.dll and *.a files in the lib folder. Takes only a few seconds to build in my laptop.

For those who are lazy, here’s the pre-compiled libraries for MinGW (MinGW 4.8.6, GCC 4.8.1, GLEW 1.10.0, Windows 8.1): download link [mediafire]


7 thoughts on “GLEW for MinGW in Windows

  1. mostraba errores al usar la palabra “gcc” y “ar”, lo solucione con esto.
    “C:\Program Files (x86)\CodeBlocks\MinGW\bin\gcc.exe”
    “C:\Program Files (x86)\CodeBlocks\MinGW\bin\ar.exe”

    MUCHAS GRACIAS AMIGO, tenia horas buscando esto 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s