Author Topic: Problems linking GLEW library  (Read 18051 times)

Offline TheChuckster

  • Single posting newcomer
  • *
  • Posts: 4
Problems linking GLEW library
« on: November 21, 2007, 01:05:30 am »
I'm trying to compile my new 3D engine in Code::Blocks, but for some reason, the linking step fails because all of the references to OpenGL extensions in the Glew32 library are undefined. I'm not sure why, because I have the include and lib search directories set to where GLEW is on my system. I tried messing around with the library order, too, but I'm just not having any luck. The linker is finding the library, but it's not using it. The odd thing is that it doesn't think glewInit() is undefined, but it still throws error messages for each OpenGL extension function that I am using. I think this problem pertains to how I am using Code::Blocks, because my Linux version's Makefile handles it fine. Am I missing something important?

Linker settings:
Link libraries:
mingw32
SDLmain
SDL.dll
SDL_ttf
SDL_image
SDL_mixer
user32
gdi32
winmm
dxguid
glew32
opengl32
glu32

I've tried moving glew32 before and after glu32 without avail.

Search directories:
Compiler:
L:\SDL-1.2.11\include
L:\glew\include

Linker:
L:\SDL-1.2.11\lib
L:\glew\lib

Quote
-------------- Build: Debug in engine ---------------

Compiling: hdr.cpp
Linking console executable: bin\Debug\engine.exe
obj\Debug\hdr.o: In function `ZN12HDR_Renderer22CheckFrameBufferStatusEv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:13: undefined reference to `_imp____glewCheckFramebufferStatusEXT'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer6ResizeEii':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:83: undefined reference to `_imp____glewBindRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:84: undefined reference to `_imp____glewRenderbufferStorageEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:85: undefined reference to `_imp____glewBindRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:86: undefined reference to `_imp____glewRenderbufferStorageEXT'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer4InitEv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:122: undefined reference to `_imp____glewUseProgramObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:136: undefined reference to `_imp____glewUseProgramObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:158: undefined reference to `_imp____glewGenFramebuffersEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:160: undefined reference to `_imp____glewGenRenderbuffersEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:162: undefined reference to `_imp____glewBindRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:163: undefined reference to `_imp____glewRenderbufferStorageEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:166: undefined reference to `_imp____glewBindRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:167: undefined reference to `_imp____glewRenderbufferStorageEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:170: undefined reference to `_imp____glewBindRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:171: undefined reference to `_imp____glewRenderbufferStorageEXT'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer19BeginRenderHDRImageEv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:183: undefined reference to `_imp____glewBindFramebufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:186: undefined reference to `_imp____glewFramebufferTexture2DEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:187: undefined reference to `_imp____glewFramebufferTexture2DEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:188: undefined reference to `_imp____glewFramebufferRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:192: undefined reference to `_imp____glewDrawBuffersARB'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer17EndRenderHDRImageEv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:256: undefined reference to `_imp____glewDrawBuffersARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:257: undefined reference to `_imp____glewFramebufferTexture2DEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:258: undefined reference to `_imp____glewBindFramebufferEXT'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer12BlurHDRImageEv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:278: undefined reference to `_imp____glewBindFramebufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:280: undefined reference to `_imp____glewFramebufferRenderbufferEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:283: undefined reference to `_imp____glewFramebufferTexture2DEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:298: undefined reference to `_imp____glewFramebufferTexture2DEXT'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:319: undefined reference to `_imp____glewBindFramebufferEXT'
obj\Debug\hdr.o: In function `ZN12HDR_Renderer18RenderSceneWithHDREv':L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:333: undefined reference to `_imp____glewActiveTextureARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/hdr.cpp:337: undefined reference to `_imp____glewActiveTextureARB'
obj\Debug\primitives.o: In function `ZN3Box6RenderEv':L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:36: undefined reference to `_imp____glewActiveTextureARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:43: undefined reference to `_imp____glewActiveTextureARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:56: undefined reference to `_imp____glewMultiTexCoord2fARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:57: undefined reference to `_imp____glewMultiTexCoord2fARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:59: undefined reference to `_imp____glewMultiTexCoord2fARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:60: undefined reference to `_imp____glewMultiTexCoord2fARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:62: undefined reference to `_imp____glewMultiTexCoord2fARB'
obj\Debug\primitives.o:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:63: more undefined references to `_imp____glewMultiTexCoord2fARB' follow
obj\Debug\primitives.o: In function `ZN3Box6RenderEv':L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:149: undefined reference to `_imp____glewActiveTextureARB'
obj\Debug\primitives.o: In function `ZN6Sphere6RenderEv':L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:158: undefined reference to `_imp____glewActiveTextureARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:165: undefined reference to `_imp____glewActiveTextureARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:179: undefined reference to `_imp____glewActiveTextureARB'
obj\Debug\primitives.o: In function `ZN8Cylinder6RenderEv':L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:188: undefined reference to `_imp____glewActiveTextureARB'
obj\Debug\primitives.o:L:/Documents and Settings/Administrator/Desktop/engine_new/primitives.cpp:195: more undefined references to `_imp____glewActiveTextureARB' follow
obj\Debug\shader.o: In function `Z12printInfoLogj':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:11: undefined reference to `_imp____glewGetObjectParameterivARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:16: undefined reference to `_imp____glewGetInfoLogARB'
obj\Debug\shader.o: In function `ZN6Shader4LoadESsSs':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:28: undefined reference to `_imp____glewCreateShaderObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:29: undefined reference to `_imp____glewCreateShaderObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:37: undefined reference to `_imp____glewShaderSourceARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:38: undefined reference to `_imp____glewShaderSourceARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:43: undefined reference to `_imp____glewCompileShaderARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:44: undefined reference to `_imp____glewCompileShaderARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:49: undefined reference to `_imp____glewCreateProgramObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:50: undefined reference to `_imp____glewAttachObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:51: undefined reference to `_imp____glewAttachObjectARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:53: undefined reference to `_imp____glewLinkProgramARB'
obj\Debug\shader.o: In function `ZN6Shader6EnableEv':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:59: undefined reference to `_imp____glewUseProgramObjectARB'
obj\Debug\shader.o: In function `ZN6Shader7DisableEv':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:64: undefined reference to `_imp____glewUseProgramObjectARB'
obj\Debug\shader.o: In function `ZN6Shader10SetUniformESsi':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:69: undefined reference to `_imp____glewGetUniformLocationARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:70: undefined reference to `_imp____glewUniform1i'
obj\Debug\shader.o: In function `ZN6Shader10SetUniformESsf':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:75: undefined reference to `_imp____glewGetUniformLocationARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:76: undefined reference to `_imp____glewUniform1f'
obj\Debug\shader.o: In function `ZN6Shader10SetUniformESsffff':L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:81: undefined reference to `_imp____glewGetUniformLocationARB'
:L:/Documents and Settings/Administrator/Desktop/engine_new/shader.cpp:82: undefined reference to `_imp____glewUniform4f'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
46 errors, 0 warnings

Offline TheChuckster

  • Single posting newcomer
  • *
  • Posts: 4
Re: Problems linking GLEW library
« Reply #1 on: March 08, 2008, 09:44:31 pm »
Just in case anyone else here has to bash their head over this like I did, here's how I fixed it. I ended up having to link GLEW statically using glew32s as my lib instead of glew32. Also, before I included the GL/glew.h header file in my code, I did a #define GLEW_STATIC and it ended up working. I'm still not sure why I can't get GLEW to work dynamically with Code::Blocks/MinGW32...

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Problems linking GLEW library
« Reply #2 on: March 09, 2008, 12:58:01 pm »
It works nicely both as static and dynamic build if you have built it with the correct flags and if you use the same flags when building the program later.
I haven't used GLEW for 10-11 months now, but I'm sure that both worked without any problems out of the box.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."