views:

24

answers:

1

I am trying to use geometry shaders in my OpenGL application that is currently using Freeglut, and I am trying to use GLEW to do that because as I understand it, the geometry shader functionality is in an extension. My include order is as follows:

   #define GLEW_STATIC
   #include <glew.h>
   #include "freeglut.h"

However when I do this I get lots of linker errors like the following:

   error LNK2001: unresolved external symbol ___glewAttachShader

I do not receive any errors when I only use the basic OpenGL functionality (that it, things that are not in the extensions) so I know that the compiler is finding all the "basic" libraries like glu32 etc. I am using Visual Studio 2008. Any suggestions?

+2  A: 

It's a linker error that says it did not find a glew entrypoint.

Link against the glew library (you did not see the error before because you did not use any extension, I assume).

Edit: Actually, this is directly related to your usage of "GLEW_STATIC".

From the GLEW page:

On Windows, you also have the option of adding the supplied project file glew_static.dsp to your workspace (solution) and compile it together with your other projects. In this case you also need to change the GLEW_BUILD preprocessor constant to GLEW_STATIC when building a static library or executable, otherwise you get build errors.

What this says is that it is your responsibility to build and include the glew source files when you use the GLEW_STATIC setup.

Bahbar
You mean glew32.lib? I am doing that I think - I put the glew32.lib file from the zip file into the visual studio lib directory as instructed, and then I added that directory both to the "additional library directories" in linker->general and "additional dependencies" in linker->input, but I still get that error. Is this the library you are talking about?
Alex319
@Alex319: Yes. The error says the linker can't find entrypoints that should be in there. Can you check your linker command line ? (properties/Linker/Command Line)
Bahbar
@Alex319: never mind... see my update.
Bahbar