OpenGL + GLEW + MinGW binding problem

I get undefined links when creating my project. Here's the build log:

**** Build of configuration Debug for project test **** **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\test.o ..\src\test.cpp g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\window.o ..\src\window.cpp ..\src\window.cpp: In member function 'void Window::StartRenderContext()': ..\src\window.cpp:150:24: warning: NULL used in arithmetic ..\src\window.cpp:161:28: warning: NULL used in arithmetic ..\src\window.cpp:174:24: warning: NULL used in arithmetic g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o src\window.o: In function `ZN6Window18StartRenderContextEv': C:\eclipse\workspace\test\Debug/../src/window.cpp:101: undefined reference to ` wglCreateContext@4 ' C:\eclipse\workspace\test\Debug/../src/window.cpp:102: undefined reference to ` wglMakeCurrent@8 ' C:\eclipse\workspace\test\Debug/../src/window.cpp:115: undefined reference to `glewInit' C:\eclipse\workspace\test\Debug/../src/window.cpp:125: undefined reference to ` wglMakeCurrent@8 ' C:\eclipse\workspace\test\Debug/../src/window.cpp:126: undefined reference to ` wglDeleteContext@4 ' C:\eclipse\workspace\test\Debug/../src/window.cpp:148: undefined reference to `__wglewChoosePixelFormatARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:159: undefined reference to `__wglewChoosePixelFormatARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:185: undefined reference to `__wglewCreateContextAttribsARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:194: undefined reference to `__wglewCreateContextAttribsARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:204: undefined reference to `__wglewCreateContextAttribsARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:214: undefined reference to `__wglewCreateContextAttribsARB' C:\eclipse\workspace\test\Debug/../src/window.cpp:227: undefined reference to ` wglMakeCurrent@8 ' collect2: ld returned 1 exit status Build error occurred, build is stopped Time consumed: 8128 ms. 

Here is my link:

 g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o 

It is right? I use 64 bit glew binaries (I think 32s don't mean anything). Were they intended only for a visual studio?

Here includes in my code:

 #include "Windows.h" #include "GL/glew.h" #include "GL/wglew.h" #include "GL/gl.h" #include "GL/glu.h" #include "test.h" 

I use Eclipse Indigo CDT, MinGW, Win32, OpenGL and glew.

+4
source share
1 answer

I solved the "glew undefined reference" problem.

My development environment is an eclipse CDT with MinGW on Windows 7 (x64).

The solution consists of the following three steps:

  • Add Source: #define GLEW_STATIC
  • Add Linker Flag: -lglew32s -lopengl32 -lfreeglut
  • Add compilation flag: gcc -DGLEW_STATIC

If necessary, you need to add -lglu32 -glut32 etc.

+1
source

All Articles