Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with GLEW using MinGW: Undefined reference to '_imp__glewExperimental.'

I'm using GLEW version 1.10.0 with MinGW (Through the CodeBlocks IDE), running on Windows 8. I downloaded the Windows binaries from the GLEW website, and have been linking to the libraries included with that build.

I have a linking problem that I just can't seem to find an answer to. I have followed the installation on the GLEW home page. I have referenced the linker to the glew32.lib, as well as the other required libs such as opengl32 and glu32.

Unfortunately, compiling this code (I'm also using GLFW for context/window management):

#include <stdio.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>

#define TRUE 1
#define FALSE 0

int main()
{
GLFWwindow *window;

if (!glfwInit())
    return -1;

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3.0);
window = glfwCreateWindow(640, 480, "Hello World!", NULL, NULL);

if (!window)
{
     glfwTerminate();
     return -1;
}

glfwMakeContextCurrent(window);

// Initialize GLEW
glewExperimental=TRUE;
GLenum err = glewInit();
if (err!=GLEW_OK)
    fprintf(stderr, "Could not initialize GLEW!");

printf("%s\n", glGetString(GL_VERSION));
while (!glfwWindowShouldClose(window))
{
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT);

    glfwSwapBuffers(window);

    glfwPollEvents();
}

glfwTerminate();
return 0;
}

I get the error:

*undefined reference to imp_glewExperimental*

Even though I'm new to C, as far as I understand, this means that I'm referring to something which has no definition, which generally means the library is missing. In this case though, I have included the library, and I got no errors whatsoever about the other GLEW references I make, such as glewInit, which I feel it should also complain about should it be a problem of missing libraries.

I've tried to search the web but I simply haven't found anything on this problem.

Anyone got any ideas? :)

Thank you all very much for your time. It is much appriciated.

like image 428
CodingBeagle Avatar asked Jul 29 '13 02:07

CodingBeagle


1 Answers

It seems I have solved the problem. For anyone who'd like to know, it appears the problem was the pre-build Windows binaries from the GLEW website, because they originate from Visual Studio (they are .lib files). I was using MinGW to do compilation. As soon as I tried to compile GLEW myself using MinGW to create a .a archive, it worked.

There's already a great answer here on stackoverflow on how to compile GLEW for MinGW, and can be found right here.

like image 123
CodingBeagle Avatar answered Oct 12 '22 22:10

CodingBeagle