Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL Linking error? Unresolved external glCreateShader()

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! :)

like image 658
Joey Dewd Avatar asked Dec 07 '25 08:12

Joey Dewd


2 Answers

Grab a copy of GLEW to handle extension loading.

Doing it by hand is...annoying.

like image 153
genpfault Avatar answered Dec 08 '25 22:12

genpfault


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.

like image 27
sheu Avatar answered Dec 08 '25 22:12

sheu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!