Undefined references errors when getting started with glwf

mandelcreme wrote on Tuesday, July 09, 2013:

Hi there.

I just started to program with glfw. While trying to create a simple window I always get these undefined reference errors: (not be surprised, I’m german)

#!cpp
Fehler:undefined reference to `_imp__glfwInit'    
Fehler:undefined reference to `_imp__glfwCreateWindow'    
Fehler:undefined reference to `_imp__glfwTerminate'    
Fehler:undefined reference to `_imp__glfwMakeContextCurrent'    
Fehler:undefined reference to `_imp__glfwSwapBuffers'    
Fehler:undefined reference to `_imp__glfwPollEvents'    
Fehler:undefined reference to `_imp__glfwWindowShouldClose'    
Fehler:undefined reference to `_imp__glfwTerminate'    
collect2.exe:-1: Fehler:error: ld returned 1 exit status    

In this case I use the glfw3dll library. When I use the glfw3 library the error messages are the same, but without “imp_”.

That is how my .pro-file looks like:

#!cpp
TEMPLATE = app
CONFIG += console
CONFIG -= qt

SOURCES += main.cpp \

LIBS += -lglfw3dll -lopengl32 -lglu32

The libraries will be found. But it seems that there are some linker problems.

That is my main-file:

#!cpp
#define GLFW_DLL
#include <GLFW/glfw3.h>

using namespace std;

int main()
{
    GLFWwindow* window;

    // initialize library
    if(!glfwInit()){
        return -1;
    }

    window = glfwCreateWindow(640,480,"Test", NULL, NULL);

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

    glfwMakeContextCurrent(window);

    while(!glfwWindowShouldClose(window)){

       glfwSwapBuffers(window);

       glfwPollEvents();
    }

    glfwTerminate();

    return 0;
}

I have seen the other threads about almost the same problem. But they didn’t help me.
Can anybody tell me, what I’m doing wrong?

Note: I use the Qt Creator 5.1.0.

Many thanks in advance.

phoenix94 wrote on Wednesday, July 10, 2013:

Which platform are you using? Linux, Windows, Max, Version, etc.?

Maybe you used the wrong library? E.g. 64Bit on 32Bit?

But I know these Problems. I need hours to get OpenGl work. :smiley:

mandelcreme wrote on Saturday, July 13, 2013:

Hi,

I’m using Wondows 7 (64 bit).
And yes, I tried to work with the 64Bit library, but without having MS Visual C++ 2012 installed…

The 32Bit library works. But I still would like to use the 64Bit. Now I have the MS Visual C++ 2012 redistributable. But it seems that I also need MinGW-w64.

So, I’m still working on it…

Thanks for your answer.