I have been trying to compile GLEW with MINGW on Windows as explained here However I get the "commands commence before first target"
Makefile (I cannot get the formatting to work here)
Thanks
Make expect “rules” with the following shape:
target: prerequisites ...
command
...
You need to define a target in your makefile before the first call to gcc. Just add a line with glew:
in the beginning. Each line with a command need to start with a tab character.
Have a look at the introduction section of the make manual for more information: https://www.gnu.org/software/make/manual/html_node/Introduction.html
modified version of your makefile (makefile.mod)
## makefile based on answer http://stackoverflow.com/a/6005262/663518
## http://stackoverflow.com/questions/6005076/building-glew-on-windows-with-mingw
.PHONY: glew
glew: libs exe
## libs
libs: lib/glew32.dll lib/glew32mx.dll
lib/glew32.dll:
@echo ##compiling libglew32
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
lib/glew32mx.dll:
@echo ##compiling libglew32mx
gcc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
ar cr lib/libglew32mx.a src/glew.mx.o
## glewinfo and visualinfo programs.
exe: bin/glewinfo.exe bin/visualinfo.exe
bin/glewinfo.exe: lib/glew32.dll
@echo ##compiling glewinfo.exe
gcc -c -O2 -Wall -W -Iinclude -o src/glewinfo.o src/glewinfo.c
gcc -O2 -Wall -W -Iinclude -o bin/glewinfo.exe src/glewinfo.o -Llib -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
bin/visualinfo.exe: lib/glew32.dll
@echo ##compiling visualinfo
gcc -c -O2 -Wall -W -Iinclude -o src/visualinfo.o src/visualinfo.c
gcc -O2 -Wall -W -Iinclude -o bin/visualinfo.exe src/visualinfo.o -Llib -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
> make -f makefile.mod
##compiling libglew32
gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude...
...
make -f makefile.mod libs
builds the dll
make -f makefile.mod exe
builds the exe and dll (if necessary)