Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

undefined references errors when getting started with glwf

Using GLFW
SaWa
2013-07-09
2013-07-13
  • SaWa
    SaWa
    2013-07-09

    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)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    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:

    1
    2
    3
    4
    5
    6
    7
    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:

     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
    #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.

     
    Last edit: SaWa 2013-07-09
    • phoeniX
      phoeniX
      2013-07-10

      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. :D

       
  • SaWa
    SaWa
    2013-07-13

    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.