The problem is in the header, I will try to list what I have already tried, etc. below.
First, in my understanding, in order to use OpenGL 4.0 on Windows, you have to expand or bypass the default window library since it only comes with OpenGL 1.1.
So, we have MinGW installed in C:/MinGW/. Then I configure FreeGLUT by downloading tarball from the project site . Extract and compile by running make files in accordance with the instructions with little addition --prefixto the command ./configure.
./configure --prefix=/c/Users/Owner/root/
make all
make install
Now I have freeglut in /c/Users/Owner/root/lib/, /c/Users/Owner/root/include/and so on. The next step is GLEW, my troubled child, as far as I can tell.
Download the source archive from the project website ( direct 1.7.0.zip link ). Compiling is a bit more complicated, my current recipe is from the stack overflow question Building glew on windows with mingw ". The following is an abbreviated form:
mkdir lib/
mkdir bin/
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/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
and should be run from the "root" /path/to/glew-1.7.0/.
Now, with the configuration of the libraries "done" (without making mistakes ...) compilation of my simple program is performed using this line.
${G++} -DFREEGLUT_STATIC -DGLEW_STATIC -m32 main.cpp -o main.exe -lfreeglut_static -lopengl32 -lwinmm -lgdi32 -lglew32 -I ${ROOTPATH}/include -L ${ROOTPATH}/lib --static
Now, to decompose it a bit and go over why I have different “extra” arguments and show you what errors and problems I have already come across and solved.
-DFREEGLUT_STATIC -lfreeglut_static -lfreeglut, . , freeglut.-DGLEW_STATIC .-lwinmm : freeglut_init.c:(.text+0x5d9): undefined reference to '_timeBeginPeriod@4'.-lgdi32 : c:/Users/Owner/root//lib\libfreeglut_static.a(freeglut_init.o):freeglut_init.c:(.text+0x58c): undefined reference to '_GetDeviceCaps@8'
:
c:/Users/Owner/root
c:/Users/Owner/root
c:/Users/Owner/root
, (main.cpp), .
#include <GL/glew.h>
#include <GL/freeglut.h>
int main(int argc, char **argv) {
glEnableVertexAttribArray(0);
}
?