error: undefined reference to `__glewDeleteBuffers'

I'm working with OpenGL and glew32 and, while trying to do some work with buffer functions, came up with these errors:

In function `ZN6spriteD1Ev':|25|undefined reference to `__glewDeleteBuffers'
In function `ZN6sprite4initEffff':|36|undefined reference to `__glewGenBuffers'
|52|undefined reference to `__glewBindBuffer'
|53|undefined reference to `__glewBufferData'
In function `ZN6sprite4drawEv':|56|undefined reference to `__glewBindBuffer'
|57|undefined reference to `__glewEnableVertexAttribArray'
|58|undefined reference to `__glewVertexAttribPointer'|
|60|undefined reference to `__glewDisableVertexAttribArray'
|61|undefined reference to `__glewBindBuffer'
||=== Build failed: 9 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|


Here's the immensly long code where I think the problem lies:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//I don't know what these are called!  The #include and #define part.
#include <SDL.h>
#define GLEW_STATIC
#include <glew.h>
#include <iostream>
#include <string>
#undef main

using namespace std;

//My gigantic sprite class.  Sorry for the length :P
class sprite{
    public:
        sprite(){}
        ~sprite(){
            if(_vboID!=0){
                glDeleteBuffers(0,&_vboID);
            }
        }

        void init(float x, float y, float width, float height){
            _x=x;
            _y=y;
            width=_width;
            height=_height;

            if (_vboID==0){
                glGenBuffers(1, &_vboID);
            }

            float vertex_data[12];
            vertex_data[0]=x+width;
            vertex_data[1]=y+height;
            vertex_data[2]=y;
            vertex_data[3]=y+height;
            vertex_data[4]=x;
            vertex_data[5]=y;
            vertex_data[6]=x;
            vertex_data[7]=y;
            vertex_data[8]=x+width;
            vertex_data[9]=y;
            vertex_data[10]=x+width;
            vertex_data[11]=y+height;
            glBindBuffer(GL_ARRAY_BUFFER,_vboID);
            glBufferData(GL_ARRAY_BUFFER,sizeof(vertex_data),vertex_data,GL_STATIC_DRAW);
        }
        void draw(){
            glBindBuffer(GL_ARRAY_BUFFER,_vboID);
            glEnableVertexAttribArray(0);
            glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,0);
            glDrawArrays(GL_TRIANGLES,0,6);
            glDisableVertexAttribArray(0);
            glBindBuffer(0,_vboID);
        }
    private:
        float _x;
        float _y;
        float _width;
        float _height;
        GLuint _vboID;
};

//The main function.  There is another class that runs the game and uses functions from the Sprite class
int main(int* argc, char** argv){
    Main_Game game_obj;
    game_obj.run();

    return 0;
}


I am using CodeBlocks and have already done the search directory linking and linker settings stuff. I'm kind of new with OpenGL and was mostly following along with this tutorial here: https://www.youtube.com/watch?v=W_OctRsu754&index=8&list=PLSPw4ASQYyymu3PfG9gxywSPghnSMiOAW
What should I do? Sorry for dumping all of that code on you.
Last edited on
I don't understand what that means. I think you're telling me to link the library -lGLEW?

I tried adding that under the Project Build Options Linker tab, using both lower and uppercase. Both times I got this:
cannot find -lGLEW


Any other suggestions?
¿have you properly installed GLEW?
perhaps you need to specify the library path -L/path/to/library_files/
Last edited on
It turns out I forgot to paste one of the GLEW lib files in the directory to which I installed GLEW. I included it and now I have a new set of undefined references:


| first defined here|
||Warning: .drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x8)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__glGetString@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0xa)||undefined reference to `_imp__glGetString@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x3e)||undefined reference to `_imp__wglGetCurrentDC@0'
(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x21)||undefined reference to `_imp__wglGetCurrentDC@0'


I should note that these are all from the \lib directory to where I installed GLEW, rather than the main.cpp that the others were. I should also note that I am new at this business and won't understand technical speak. I don't know what a "library path" is. Can you or anyone else who replies to this topic explain your answers in layman's terms? It would help me immensely! Thanks in advance and sorry for the trouble.
I suppose that the problem is that the order of your libraries is incorrect
http://www.cplusplus.com/forum/general/113904/#msg622062
Try first GLEW, then GLU, then GL

Post your build command, your current code and the messages that it gives you.
(the code that you've posted does not compile)


> I don't know what a "library path" is
A set of directories to search for libraries when using the -l flag
-lGLEW says to link against the libGLEW.a file, but the linker needs to know where that file is.
I included the build libraries like you told me to:

1
2
3
4
5
6
7
8
#include <SDL.h>
#define GLEW_STATIC
#include <glew.h>
#include <GL/glu.h>
#include <GL/gl.h>
#include <iostream>
#include <string>
#undef main 


But now it's giving me this crap:


||=== Build: Debug in game (compiler: GNU GCC Compiler) ===|
..\lib\glew32.lib(glew32.dll)|| first defined here|
||Warning: .drectve `/DEFAULTLIB:"LIBCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x7)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x8)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__glGetString@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0xa)||undefined reference to `_imp__glGetString@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x4)||undefined reference to `_imp__wglGetProcAddress@4'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x3e)||undefined reference to `_imp__wglGetCurrentDC@0'|
..\lib\glew32s.lib(tmp\glew_static\Release\Win32\glew.obj):(.text$mn+0x21)||undefined reference to `_imp__wglGetCurrentDC@0'|
||=== Build failed: 11 error(s), 2 warning(s) (0 minute(s), 1 second(s)) ===|


What am I doing wrong here?
Topic archived. No new replies allowed.