Glew Breaks my Program

Hi Guys,

So I have this code:

#include "glfw3.h"

int main()
{
    GLFWwindow* window;

    /*Initialize the library*/
    if(!glfwInit())
    {
        return -1;
    }

    /*Create a windowed mode window and its OpenGL context*/
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);

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

    /*Make the window's context current*/
    glfwMakeContextCurrent(window);

    /*Loop until the user closes the window*/
    while(!glfwWindowShouldClose(window))
    {
        /*Render here*/

        /*Swap front and back buffers*/
        glfwSwapBuffers(window);

        /*Poll for an process events*/
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

It launches a new window just fine with a black blank screen.

However the moment I add glew, the window stops appearing:

#include <stdio.h>
#include <stdlib.h>

#include "glew.h"
#include "glfw3.h"

int main()
{
    GLFWwindow* window;

    /*Initialize the library*/
    if(!glfwInit())
    {
        fprintf(stderr, "GLFW failed to initialise");
        return -1;
    }

    /*Create a windowed mode window and its OpenGL context*/
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);

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

    /*Make the window's context current*/
    glfwMakeContextCurrent(window);

    if(glewInit() != GLEW_OK)
    {
        fprintf(stderr, "GLEW failed to initialise");
        glfwTerminate();
        return -1;
    }

    /*Loop until the user closes the window*/
    while(!glfwWindowShouldClose(window))
    {
        /*Render here*/

        /*Swap front and back buffers*/
        glfwSwapBuffers(window);

        /*Poll for an process events*/
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

This code results in no compilation or linker errors, but nothing happens, the window stops appearing.

Any ideas as to what is going on?

As a side note that might give suggestions as to what might be going on, it also doesn’t compile if I add glewExperimetnal = true;

#include <stdio.h>
#include <stdlib.h>

#include "glew.h"
#include "glfw3.h"

int main()
{
    GLFWwindow* window;

    /*Initialize the library*/
    if(!glfwInit())
    {
        fprintf(stderr, "GLFW failed to initialise");
        return -1;
    }

    /*Create a windowed mode window and its OpenGL context*/
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);

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

    /*Make the window's context current*/
    glfwMakeContextCurrent(window);
    glewExperimental = true;

    if(glewInit() != GLEW_OK)
    {
        fprintf(stderr, "GLEW failed to initialise");
        glfwTerminate();
        return -1;
    }

    /*Loop until the user closes the window*/
    while(!glfwWindowShouldClose(window))
    {
        /*Render here*/

        /*Swap front and back buffers*/
        glfwSwapBuffers(window);

        /*Poll for an process events*/
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

It spits out undefined reference to ‘imp__glewExperimental’
collect2: Id returned 1 exit status

so maybe there’s something wrong with the .lib??? Or maybe I’ve used the wrong one in my project??? I tried different .libs that were in the pack and I get even more compile errors then, so not sure what’s going on.

t also doesn’t compile if I add glewExperimetnal = true;

Wait, what do you mean “also”? You said that it did compile with including GLEW. So, which is it: does it compile or does it not?

Does the executable get a new timestamp?

Sorry, I meant the first code and the second code compile and the third code doesn’t, so by also I meant… as a side note.

If they compile an application, you should be able to step into it and debug it. Where does it stop working?

Well it seems I might have been mixing 32 and 64 bit architecture.

When I tried running the executable, it popped up with 0xc000007b.

I THINK I have linked the correct libraries now.

Unfortunately, now I get the compile error:

error: undefined reference to `_imp__glewInit@0’

Which is wierd, because when I’m typing the function, it pops up in the hints.

I tried compiling my glew source in Qt, and Qt crashes when I try creating my own libraries. Something is very wrong with glew :S.

I think I might be installing it incorrectly, hmm still playing around with it.