Qt Creator - Linking in 2.6.0



  • Hello,

    I am unable to add any library. Currently I want to use glfw in qtcreator. Its compiled under mingw.

    I added the following lines in the .pro file

    @INCLUDEPATH += C:/glfw/include
    LIBS += -LC:/glfw/lib-mingw@

    But when I compile the glfw hello world program I get tons of different undefined reference errors. So I guess the linking didn't work. Where is the mistake?


  • Moderators

    One thing for sure the LIBS declaration is not complete. Checkout "qmake-libs":http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#libs You have only the path declaration with the capital 'L'. You need to specify also the lib itself with lower case 'l'.



  • I tried now this

    @INCLUDEPATH += C:/glfw/include
    LIBS += -LC:/glfw/lib -lglfw@

    but I still get the same undefined reference errors. :(


  • Moderators

    You should post the error messages then.



  • for this program
    @
    #include <GL/gl.h>
    #include <GL/glfw.h>

    #include <stdlib.h>
    int main()
    {
    if(glfwInit())
    {
    return 0;
    }
    return 0;
    }@

    error: undefined reference to `glfwInit'

    error: collect2: ld returned 1 exit status


  • Moderators

    Where is the library placed? Provide path and name of lib.
    Note, you changed the path to the lib between your first and second post.



  • yes i changed the name of the lib folder because I thought the hyphen maybe causes trouble.

    the lib is located at C:/glfw
    include /
    GL/
    glfw.h


    lib/
    glfw.dll
    libglfw.a
    libglfwdll.a


  • Moderators

    The only things I would try is to make sure that:

    • qmake was run after changes to .pro.
    • Making sure that the same MinGW version was used for compilation of the lib and the my code.
    • Since the project is still rather small, you can easily do a complete rebuild.
    • It looks like there is only a release version of the lib available. AFAIK you may mix debug and release version, but I do not myself. So I would try to avoid.

    Otherwise I am lost here.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.