Reputation: 84
I use eclipse CDT to write my C++ Programs. But eclipse and the GCC compiler can't recognize glShaderSource(). I do the following to "load" the header:
#include <GL/glew.h>
#include "Shader.h"
And that is the Code, which produces the Errors:
void Shader::setShaders(const char* vsFile, const char* fsFile) {
char *vs, *fs;
v = glCreateShader(GL_VERTEX_SHADER);
f = glCreateShader(GL_FRAGMENT_SHADER);
vs = textFileRead(vsFile);
fs = textFileRead(fsFile);
const char * vv = vs;
const char * ff = fs;
glShaderSource(v, 1, &vv, NULL);
glShaderSource(f, 1, &ff, NULL);
free(vs);
free(fs);
glCompileShader(v);
glCompileShader(f);
p = glCreateProgram();
glAttachShader(p, v);
glAttachShader(p, f);
glLinkProgram(p);
glUseProgram(p);
}
Every GL-Function can't be found. For Example this error is given:
Function 'glCreateShader' could not be resolved
Eclipse says, that the glext-header can be recognized, and I can even take a look at it. Other GL-Functions work (1.0-Functions).
[ OLD: ] I have installed GLext via
sudo pacman -S glext
And then installed the Package gtkglext
, which was the only choice.
I really have no plan what to do. There is also no additional libGLEXT.so or something like that, I only have libGL, libGLU and other.
Upvotes: 0
Views: 1529
Reputation: 58
I've had similar problems with GL extension functions. I managed to fix it by downloading GLEW source and statically linking to it in my project. This was annoying however so I searched deeper in the forums and found this solution. On linux you just need to dedine GL_GLEXT_PROTOTYPES. This solution will not work on Windows! As always it is "easier" on windows so one will need to fight with the glew or glext configuration and linking.
For me it worked when I added it in the project options of QtCreator. Every IDE should have a place with defines in the project/build options. I added this to the list: -DGL_GLEXT_PROTOTYPES
I have #include but I am not sure I need it :) anyways I haven't linked explicitly to any other libraries but GL and GLU.
Upvotes: 0
Reputation: 162174
Your problem is, that extension functions are not exposed by the OpenGL API library through regular exports, but through the extension mechanism. Loading extensions is done using a function xxxGetProcAddress
, where xxx
is plattform specific. Since loading extensions is tedious, but the code for it can be autogenerated from the OpenGL specification the GLEW project did exactly that.
GLEW ( http://glew.sf.net ) is a extension loader/wrapper library that does the tedious task for you. There are other such libraries, but GLEW is the by far best maintained.
Upvotes: 2