Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 13

Thread: Issue compiling OpenGL program that uses GLEW

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    5

    Issue compiling OpenGL program that uses GLEW

    Hi all,
    This is my first post here. I've been learning C++, SDL, and OpenGL the last few weeks and finally ran into a problem I can't seem to get around.
    I'm using Code::Blocks in Windows 7.
    I was able to set up OpenGL, install freeglut, etc. The sample program that CB gives compiles and works fine.

    I then started to go through some tutorials. The first one worked fine (which was opening an OpenGL window), but when I got to the second, where it puts a dot on the screen, it started using glew.h.

    Whenever I compile the code they have:

    Code :
    #include <stdio.h>
    #include <GL/glew.h>
    #include <GL/freeglut.h>
    #include "math_3d.h"
     
    GLuint VBO;
     
    static void RenderSceneCB()
    {
        glClear(GL_COLOR_BUFFER_BIT);
     
        glEnableVertexAttribArray(0);
        glBindBuffer(GL_ARRAY_BUFFER, VBO);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
     
        glDrawArrays(GL_POINTS, 0, 1);
     
        glDisableVertexAttribArray(0);
     
        glutSwapBuffers();
    }
     
     
    static void InitializeGlutCallbacks()
    {
        glutDisplayFunc(RenderSceneCB);
    }
     
    static void CreateVertexBuffer()
    {
        Vector3f Vertices[1];
        Vertices[0] = Vector3f(0.0f, 0.0f, 0.0f);
     
     	glGenBuffers(1, &VBO);
    	glBindBuffer(GL_ARRAY_BUFFER, VBO);
    	glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
    }
     
     
    int main(int argc, char** argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
        glutInitWindowSize(1024, 768);
        glutInitWindowPosition(100, 100);
        glutCreateWindow("Tutorial 02");
     
        InitializeGlutCallbacks();
     
        // Must be done after glut is initialized!
        GLenum res = glewInit();
        if (res != GLEW_OK) {
          fprintf(stderr, "Error: '%s'\n", glewGetErrorString(res));
          return 1;
        }
     
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
     
        CreateVertexBuffer();
     
        glutMainLoop();
     
        return 0;
    }

    I keep getting the following error:


    Code :
    obj\Debug\main.o||In function `RenderSceneCB':|
    C:\C Programs\OpenGL Test\main.cpp|33|undefined reference to `_imp____glewEnableVertexAttribArray'|
    C:\C Programs\OpenGL Test\main.cpp|34|undefined reference to `_imp____glewBindBuffer'|
    C:\C Programs\OpenGL Test\main.cpp|35|undefined reference to `_imp____glewVertexAttribPointer'|
    C:\C Programs\OpenGL Test\main.cpp|39|undefined reference to `_imp____glewDisableVertexAttribArray'|
    obj\Debug\main.o||In function `CreateVertexBuffer':|
    C:\C Programs\OpenGL Test\main.cpp|55|undefined reference to `_imp____glewGenBuffers'|
    C:\C Programs\OpenGL Test\main.cpp|56|undefined reference to `_imp____glewBindBuffer'|
    C:\C Programs\OpenGL Test\main.cpp|57|undefined reference to `_imp____glewBufferData'|
    obj\Debug\main.o||In function `main':|
    C:\C Programs\OpenGL Test\main.cpp|72|undefined reference to `_imp__glewInit'|
    C:\C Programs\OpenGL Test\main.cpp|74|undefined reference to `_imp__glewGetErrorString'|
    ||=== Build finished: 9 errors, 0 warnings (0 minutes, 0 seconds) ===|

    (Note, the last two errors about glewInit and glewGetErrorString have more characters on the ends of them, but I can't post it like that since I get an error about URLs.)

    I've done several internet searches and it seems most people that get the errors are able to solve them in ways that don't pertain to me (such as leaving out a header file, etc.)
    I'm stumped and am unable to go any further.
    If anyone could give some insight how to to get past this, I'd appreciate it!
    Last edited by MilesAway1980; 05-22-2013 at 03:12 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •