3
votes

I'm working on an OpenGL program to test out shaders and trying to compile them. However, the call to glCreateShader() (and other shader calls like glDeleteShader) give the following error:

(this error is from glCreateShader())

Error   3   error LNK2001: unresolved external symbol _pglCreateShader  

I'm using Visual Studio 2012 and on windows 7. Got one of the latest nvidia cards including the latest drivers so can't be my OpenGL version.

I'm using the glTools header files for all the helper functions for the OpenGL Superbible 4th edition. Not sure if there is an error in using these files?

I'll post my includes in case this could be of any help as well.

#pragma once

#include <Windows.h>

// Basic C++ includes
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
using namespace std;

// OpenGL specific and GUI includes
#include "shared/gltools.h"
#include "shared/math3d.h"
#include <SOIL.h>

And linker options:

soil.lib;opengl32.lib;gltools.lib;


Oké, the problem has been solved thanks to the answers:

I edited my glTools.h to include 'gl/glew.h' instead of "glee.h", added a ;glew32.lib option to my linker and added glewInit() before entering the main loop. I've also added the GLEW libs,dlls and includes into the appropriate folder and all the functions work like they should! :)

2
What does glGetString(GL_VERSION) return? If it's below version 2.0, then the openGL Version will not support the creation of shaders. I'm not sure what the glTools header contains. Does it, or any of its includes, contain a declaration for glCreateShader()?Weaver

2 Answers

3
votes

Grab a copy of GLEW to handle extension loading.

Doing it by hand is...annoying.

2
votes

On Windows, you use WGL, and when using WGL you can't just link against the GL functions directly. All the functions you get are these; you're supposed to dynamically grab the pointer to the GL entry point you want with wglGetProcAddress (as in here) before you can use them.

Basically, OpenGL on Windows is a PITA if you do the GL entrypoint function pointer loading manually. It's much easier to use a utility library to grab the pointers for you, such as GLEW.