SFML community forums

Help => General => Topic started by: Lolilolight on February 27, 2014, 08:48:36 pm

Title: Problem with glew.
Post by: Lolilolight on February 27, 2014, 08:48:36 pm
I, I'm trying to use glew in a library using SFML to add the 3D but, it doesn't seems to work.

I have those errors when I want to use my library : (And it happens since I'm using tdm-gcc, but when I link only opengl there isn't any link errors.)

Code: [Select]
C:\ODFAEG\lib\libsfgl-graphics-s.a(renderTarget.cpp.obj):renderTarget.cpp|| undefined reference to `_imp____GLEW_EXT_blend_func_separate'|
C:\ODFAEG\lib\libsfgl-graphics-s.a(renderTarget.cpp.obj):renderTarget.cpp|| undefined reference to `_imp____glewBlendFuncSeparateEXT'|
C:\ODFAEG\lib\libsfgl-graphics-s.a(renderTarget.cpp.obj):renderTarget.cpp|| undefined reference to `_imp____GLEW_EXT_blend_func_separate'|
C:\ODFAEG\lib\libsfgl-graphics-s.a(renderTarget.cpp.obj):renderTarget.cpp|| undefined reference to `_imp____glewBlendFuncSeparateEXT'|
C:\ODFAEG\lib\libsfgl-graphics-s.a(renderTarget.cpp.obj):renderTarget.cpp|| undefined reference to `_imp____glewBlendFuncSeparateEXT'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|

It seems it doesn't find the glew libs in my lib using SFML, it compile well when I compile my library but it fails when I want to use it.
Title: Re: Problem with glew.
Post by: Laurent on February 27, 2014, 11:03:57 pm
Since your library is static, it doesn't "include" or link any 3rd-party dependency (unless you use the ugly trick that SFML used before), so you have to link every dependency of your library into the final app.

If you're creating static libraries with dependencies, you should read more about what static libraries are and how they work. Knowing this helps to solve this kind of problems.
Title: Re: Problem with glew.
Post by: Lolilolight on February 28, 2014, 11:16:26 am
I've linked glew in my final project :

I've linked the file libglew32.a and I've defined the GLEW_STATIC macro but it doesn't solve the problem.

I think I'll have to compile this dynamically...
Title: Re: Problem with glew.
Post by: Laurent on February 28, 2014, 01:53:57 pm
Quote
I've defined the GLEW_STATIC macro
You probably did it wrong, since the linker is looking for imported functions (the "_imp____" prefix).
Title: Re: Problem with glew.
Post by: Lolilolight on February 28, 2014, 01:56:31 pm
Yes it seems that I did somethings wrong then, I'll check. ^^
Title: Re: Problem with glew.
Post by: Lolilolight on March 02, 2014, 04:04:46 pm
Ok it seems that code blocks always check for the dynamic glew library. (It's certainly because of the cmake files config)

So to don't wast time I've compiled glew dynamically, linked it to the project and it works :

Title: Re: Problem with glew.
Post by: Lolilolight on March 03, 2014, 01:42:30 pm
Arf, I had simply to add this line in the CMAKE file :

add_definitions(-DGLEW_STATIC)