0

I am confused. I have seen examples programs using glCreateShader() and some using glewCreateShader().

With Windows Visual Studio 2010 I get the following error:

error LNK2019: unresolved external symbol _glCreateShader@

I am linking the following libraries (all 32-bit):

sdl2.lib
sdl2main.lib
opengl32.lib
freeglut.lib
glew32.lib
freetype255.lib

My #include statements look like this:

#include <windows.h>    
#include <glew.h>
#include <gl\gl.h>                              
#include <gl\glu.h>                             
#include <freeglut.h>

#include <SDL.h>
#define GL_GLEXT_PROTOTYPES
#define GL_SGIX_fragment_lighting
#include "SDL_opengl.h"

Isn't glCreateShader() a standard OpenGL function that should be part of opengl32.lib?

This function is only one of many missing OpenGL functions at link time. I have another example project which links fine. It only uses GLEW, FreeGLUT and does not include SDL2 at all. Is this linker problem perhaps related to using SDL2??

Update:

I found that I had to include GLEXT.lib to get this working. The below header file inclusion also appears to work and is tidier as per what derhass was suggesting (ie. SDL_opengl.h is used instead of the regular gl.h):

#include <windows.h>                            
#include <glew.h>
#include "SDL_opengl.h"
#include <gl\glu.h>                             
#include <freeglut.h>
SparkyNZ
  • 6,266
  • 7
  • 39
  • 80
  • @derhass. I checked the similar answer but it isn't helping me at all. I am trying to use glew but I still get the linker errors. – SparkyNZ May 08 '16 at 19:18
  • It is not exactly clear what is happening. But you should definitively not include the normal GL headers if you include `glew.h`, and you never ever should `#define GL_GLEXT_PROTOTYPES` which would add declarations for functions which are not exported at all. The error message actually suggests that the glew header is not active at that point, since it would define every gl function as some _macro_ mapping to some Function with the prefix `glew` instead of `gl`, which is finally provided by the glew lib. If your linker is looking for the `gl` variant, there is something broken in that regard. – derhass May 08 '16 at 21:47
  • @derhass: I have managed to get it linking. I included GLEXT.lib and the problems have went away. I also found in some examples that I should be including SDL_opengl.h instead of the regular gl.h. I will add an answer but I have found the whole problem very confusing. – SparkyNZ May 08 '16 at 22:37

0 Answers0