Jump to content
  • Advertisement
Sign in to follow this  

OpenGL VBOs & glew undefined references

This topic is 2804 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can get Immediate Mode & Vertex Arrays to work, but not VBOs.

#include <stdlib.h>
#include <GL/glew.h>
#include <stdio.h>
#include "sdl.h"

const int NODRAW = 0;
const int IMMEDIATE = 1;
const int VERTEX_ARRAY = 2;
const int VBO = 3;

extern int method;
extern int print, delay;

GLfloat vertices[] = {
-0.2f, -0.2f, 0.0f,
-0.2f, 0.2f, 0.0f,
0.2f, 0.2f, 0.0f,
0.2f, -0.2f, 0.0f

GLfloat colors[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f

int numverts = sizeof(vertices) / (3*sizeof(GLfloat));

GLuint vboId = 0;

static int make_resources(void) {
glGenBuffers(1, &vboId);
glBindBuffer(GL_ARRAY_BUFFER, vboId);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices) + sizeof(colors), NULL, GL_STATIC_DRAW);

glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertices), sizeof(colors), colors);


return 1;

static int clean_resources(void) {
// glDeleteBuffers(1, &vboId);

static void render(void) {
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

if (method == IMMEDIATE) {

int i;
for(i = 0; i < numverts; i++) {

} else if (method == VERTEX_ARRAY) {

glVertexPointer(3, GL_FLOAT, 0, vertices);
glColorPointer(3, GL_FLOAT, 0, colors);

glDrawArrays(GL_POLYGON, 0, numverts);

} else if (method == VBO) {
// glBindBuffer(GL_ARRAY_BUFFER, vboId);

// glEnableClientState(GL_VERTEX_ARRAY);
// glEnableClientState(GL_COLOR_ARRAY);

// glVertexPointer(3, GL_FLOAT, 0, 0);
// glColorPointer(3, GL_FLOAT, 0, (GLvoid*)(numverts * 3 * sizeof(GLfloat)));

// glDrawArrays(GL_LINE_LOOP, 0, numverts);

// glDisableClientState(GL_COLOR_ARRAY);
// glDisableClientState(GL_VERTEX_ARRAY);

// glBindBuffer(GL_ARRAY_BUFFER, 0);


extern int done;

int main(int argc, char** argv) {


if (!glewIsSupported("GL_VERSION_2_0")) {
fprintf(stderr, "OpenGL 2.0 not available\n");
return 1;

if (!make_resources()) {
fprintf(stderr, "Failed to load resources\n");
return 1;

while (!done) {

return 0;

I won't bother you with initSDL() or handleInput(), but they are both in a seperate file, sdl.c, along with some ints & have a header, sdl.h. (I realise that that's a bad name, could interfer with SDL.h!)

I'm linking with:

Now If I uncomment the code in render(), make_resources() & clean_resources(), I get these errors:

build/main.o: In function `make_resources':
src/main.c:35: undefined reference to `__glewGenBuffers'
src/main.c:36: undefined reference to `__glewBindBuffer'
src/main.c:37: undefined reference to `__glewBufferData'
src/main.c:39: undefined reference to `__glewBufferSubData'
src/main.c:40: undefined reference to `__glewBufferSubData'
build/main.o: In function `clean_resources':
src/main.c:49: undefined reference to `__glewDeleteBuffers'
build/main.o: In function `render':
src/main.c:86: undefined reference to `__glewBindBuffer'
src/main.c:99: undefined reference to `__glewBindBuffer'

So what do I have to do to get glew to fix it?


Share this post

Link to post
Share on other sites
I tried using MingW using Eclipse. It was really hard to set up. The problem mainly being the library is specifically compiled using Visual Studio and no official support for the MingW library.

With that said however there are ways of getting it to run. 1) Get someone else's compiled MingW library (http://www.nuwen.net) or 2) compile it yourself [Gives access to the latest GLEW library].

I remember seeing a compiled MingW library somewhere in Google, I'll get back to you on that if I come across it.

As an alternative you could just use Microsoft Visual Studio 2008 / 2010 Express Edition and most libraries run "out of the box".

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!