Creating GLEW 1.7.0 for Windows using MinGW

This was asked quite a bit earlier: How to compile the GLEW 1.7.0 source on Windows using MinGW? The goal is to dynamically link the library to a C ++ project.

Additional info: I work with QtCreator, ergo uses qmake to create. I am on Windows 7. So far, I have tried / looked at the following links.

The used batch file used also tried to replace gcc with g ++

static with vC ++ libs, build dll.a reuse vC ++. dll

Get MSYS launched makefile

Initial Issues Information

simple things using msvc ++ GLEW binaries, works on my desktop

Unfortunately, all published solutions end with the following error messages for me when I use the compiled results in my project:

undefined reference to ` glDrawElements@16 ' debug/Ex04.o: In function `Z6initGLv': undefined reference to ` glClearColor@16 ' undefined reference to ` glEnable@4 ' debug/Ex04.o: In function `Z8updateGLv': undefined reference to ` glClear@4 ' undefined reference to ` glViewport@16 ' collect2: ld returned 1 exit status mingw32-make.exe[1]: *** [debug/ecg4.exe] Error 1 mingw32-make.exe: *** [debug] Error 2 

At the end of my mind, I consider this problem. I double and triple checked the LIBS path in qmake and the Windows path variable to include the directory where glew dll is located. Also qmake INCLUDEPATH should be ok. Here the paths in the .pro file are always:

 LIBS += -L$$quote(C:/mypath/freeglut/lib/) -lfreeglut LIBS += -L$$quote(C:/mypath/glew-1.7.0/lib/) -lglew32 -lglew32mx #LIBS+= C:/mypath/glew-1.7.0/lib/libglew32.dll.a #LIBS+= C:/Programming/glew-1.7.0/lib/libglew32mx.dll.a #includepath for project and the required libraries INCLUDEPATH += ./include INCLUDEPATH += "C:/mypath/glew-1.7.0/include" INCLUDEPATH += "C:/mypath/freeglut/include" 

So is there someone who could give a reliable set of instructions on how to get the GLEW 1.7.0 source compiled with MinGW?

+7
source share
1 answer

Ok, I solved it.

Basically, I compiled GLEW correctly, as far as I can tell. I forgot to add -lopengl32 -lglu32 to the LIBS path in my project. For some reason I need to do this on my Qt / MinGW / Windows system. On my desktop: Qt / VC ++ / Windows I do not need to do this. Does anyone have an explanation?

For those who face the same problem:

  • Download source (.zip) from GLEW Home Page
  • Compile the source, there are different ways (see links in the initial question)
    -> see below (old batch file no longer works on github)
  • Put the .dll.a files in a directory that will be part of your libs path in qmake
  • Place the .dll files in a directory that is part of the PATH system variable
  • Remember to link to opengl, glu, glew in the qmake project file

Here is a snippet of my project file:

 #Required Libraries, replace with your path # $$quote(...) for quoting pathes with spaces LIBS += -L$$quote(C:/Programming/freeglut/lib/) -lfreeglut LIBS += -L$$quote(C:/Programming/glew-1.7.0/lib/) -lglew32 -lglew32mx # the following line is not necessary when working with VS compiler, odd LIBS += -lopengl32 -lglu32 #includepath for project and the required libraries INCLUDEPATH += ./include INCLUDEPATH += "C:/Programming/glew-1.7.0/include" INCLUDEPATH += "C:/Programming/freeglut/include" 

Anyway, thanks, maybe this helps some people not to forget about dependencies :)

Cheers, Moritz


Edit: The batch file no longer works, and I just had to compile glew 1.9.0. So here are a few more notes:

  • Make sure ar.exe and gcc.exe are in your path. For a "standard QtSDK installation," these programs can be found in C: \ QtSDK \ mingw \ bin;
  • Put the following lines in the batch file in the glew-1.xy folder. This is a shortened version of the LightningIsMyName response.

     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 
  • Run the batch file. The results will be in the lib / folder. The resulting .dll and .dll.a files go together (.dll.a is what you want to tell your linker that .dll should be available to the system at runtime). .A files are for static linking.

+12
source

All Articles