glPatchParameteri not recognized on Linux

When I try to compile my OpenGL 4 program on Ubuntu 12.04 I get the following error:

undefined reference to `glPatchParameteri’|

I am including the OpenGL headers as follows:

#include <OpenGL.h>
#include <GL/gl.h>

This macro is defined in the project build options:

GL_GLEXT_PROTOTYPES

According to the terminal, my GPU supports OpenGL 4.3:

OpenGL version string: 4.3.0 NVIDIA 319.32

I have not included GLEW, as I have never needed it in the past, and do not know if it solves this problem.

well its because you dont have glew that its not working. im assuming youve been programing in early opengl, that doesnt require GLEW. but with newer opengl you need GLEW or something like it (http://www.opengl.org/wiki/OpenGL_Loading_Library). all my programs need GLEW and im pretty sure that glPatchParameteri() is a newer function. also ive never heard of OpenGL.h, i dont need it in any of my programs. try it with GLEW

I included glew:

        #include <GL/glew.h>
        #include <GL/gl.h>

I still get the same error.

I can find the function in glew.h, and I know header is the one the program is including:

typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat* values);
typedef void (GLAPIENTRY * PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value);

#define glPatchParameterfv GLEW_GET_FUN(__glewPatchParameterfv)
#define glPatchParameteri GLEW_GET_FUN(__glewPatchParameteri)

you have to first add this to your code to load the functions:
glewExperimental=TRUE;
GLenum err=glewInit();
if(err!=GLEW_OK)
{
//Problem: glewInit failed, something is seriously wrong.
cout<<“glewInit failed, aborting.”<<endl;
}
then you must link to GLEW by -lGLEW if youre using gcc from the terminal. if not you will have to figure out how to link to it.
you also should install GLEW using the packagae manager that comes with your system.
good luck :slight_smile:

Thanks, I got it to compile. I added libglew.so in the linker settings.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.