kjh
kjh

Reputation: 3411

C++ undefined reference to `_imp__glewInit@0`

Note: I have seen the post about the person having this problem in the C language because the glew.c script was not loading for him, I don't think that is my problem. From following the exact steps on the GLEW documentation website as closely as possible (and in which I saw no mention of a requirement to add a file called glew.c) I've setup glew with MinGW and extracted the dll's and libs to the appropriate folders yet at compile time I get this message:

undefined reference to `_imp__glewInit@0`

Here is my main file main.cpp:

#include <stdlib.h>
#include <iostream>
#include <windows.h>
#include <GL/glew.h>
#include <GL/glut.h>

using namespace std;

 int main(int argc, char *argv[])
{
    glutInit(&argc, argv);
    glutCreateWindow("Glew Test");
    GLenum err = glewInit();

    if (GLEW_OK != err)
    {
        cout << "Something effed up";
    }

    cout << "Awwwwwwwwhhhhh Yeeeeeeeaaaaah!!!";

return 0;
}

And here is my MakeFile:

MY_LIBS = -lglut32 -lglew32 -lopengl32 
glewex:
    g++ -g main.cpp -o glewex $(MY_LIBS)

Any ideas as to why I get this error?

Upvotes: 3

Views: 5685

Answers (2)

CodeSeven
CodeSeven

Reputation: 307

I had a similar issue. glewGetErrorString and glewInit were being reported as undefined for me. couldn't track the problem.

then i remembered i had downloaded the 64 bit version of glew while free-glut and everything else i downloaded was 32bit

so re-downloaded glew for 32 bit. and everything worked perfectly! hope that helps someone in the future.

Upvotes: 4

TheBuzzSaw
TheBuzzSaw

Reputation: 8836

Why do you insist on linking to this library externally? It causes way more trouble than it is worth.

Add glew.c to your project. Just compile it in with the rest of your source files. As long as you #define GLEW_STATIC it will work fine. Problem solved.

Even if you succeed at linking it to the library, you are then bound to one specific architecture/build/version. If you just include glew.c you will be free to build the project virtually anywhere.

Upvotes: 9

Related Questions