Results 1 to 1 of 1

Thread: QTCreator + GLEW linking in Windows

  1. #1
    Join Date
    Jul 2011
    Location
    Santa Clara, CA
    Posts
    13
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTCreator + GLEW linking in Windows

    Hey,

    Trying to get GLEW into Qt Creator and it's not working out well for me. I see there has been other threads posted about this issue, but I can't find one that has the answer.

    Using: Qt Creator 2.0.1 with QT 4.7 (32) - attempting to use built-in OpenGL (2.1.2 according to OpenGL's GetString() functionality.

    Trying to get GLEW in there, dl'ed "glew-1.7.0-win32" - put the .lib files in minGW/lib, the header files in minGW/include/GL, and the binaries/dll's in minGW/bin.

    I am calling "glewInit();" after I establish an OpenGL context (should be after) but it's not even compiling. It has no trouble there, it has trouble when I try to use the function: "glGenBuffers((GLsizei)1, &a);" - this is part of the GLEW lib.

    I modified my .pro file to have the following:
    Qt Code:
    1. LIBS += -lglew32 -LC:\Qt\2010.05\mingw\lib\glew32.lib
    2. QT += core gui opengl
    3. INCLUDEPATH += C:\Qt\2010.05\mingw\include\GL
    To copy to clipboard, switch view to plain text mode 

    This makes it so that it does NOT error when it attempts to file glew32, so it *should* be linking correctly, if I change that to something like '-lGLEW' I get an error that it can't find the lib. Though if I remove the path to the actual library so it is simply:
    Qt Code:
    1. LIBS += -lglew32
    2. QT += core gui opengl
    3. INCLUDEPATH += C:\Qt\2010.05\mingw\include\GL
    To copy to clipboard, switch view to plain text mode 

    It has the same error. Tried everything I can think of and everything I've found, error is always:
    Qt Code:
    1. debug/cube.o: In function `DrawCube':
    2.  
    3. <project_path>/cube.c:21: undefined reference to `_imp____glewGenBuffers'
    4.  
    5. collect2: ld returned 1 exit status
    6.  
    7. mingw32-make[1]: *** [debug/AnimationFramework_0.exe] Error 1
    8.  
    9. mingw32-make: Leaving directory `<project_path>'
    10.  
    11. mingw32-make: *** [debug] Error 2
    12.  
    13. The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    14. Error while building project <project_name> (target: Desktop)
    15. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    The line on cube.c:21 is: glGenBuffers((GLsizei)1, &a);

    Not sure where the name mangling is happening, but it seems like it's linking okay..kind of lost where to go. Not sure where the other function is coming from? Perhaps C++, I mean it is C++ and it's calling a C function, but I'd imagine it's okay in this context.

    Any help is appreciated.

    EDIT:
    Just for a sanity check I gave the problematic function a cpp extension so it compiles to a cpp object, the error is the same (slightly) different, reads:
    Qt Code:
    1. debug/cube.o: In function `Z8DrawCubev':
    2.  
    3. <project_path/cube.cpp:21: undefined reference to `_imp____glewGenBuffers'
    4.  
    5. collect2: ld returned 1 exit status
    6.  
    7. mingw32-make[1]: *** [debug/<final_binary>] Error 1
    8.  
    9. mingw32-make: *** [debug] Error 2
    10.  
    11. The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    12. Error while building project <project_name> (target: Desktop)
    13. When executing build step 'Make'
    To copy to clipboard, switch view to plain text mode 

    The function it's referring to (where the error is) is just called DrawCube(), the prototype is: void DrawCube(), it isn't a member function nor does it have any special attributes.

    EDIT2:
    Now the top of my .pro file looks like this:
    Qt Code:
    1. LIBS += -lglew32 -LC:\Qt\2010.05\mingw\bin -LC:\Qt\2010.05\mingw\lib
    2. QT += core gui opengl
    3. INCLUDEPATH += C:\Qt\2010.05\mingw\include\GL
    To copy to clipboard, switch view to plain text mode 

    Now it compiles, but glewInit() fails...that's typically a "I don't know where the hell to find this resource" issue..
    Last edited by Syndacate; 23rd January 2012 at 03:05.

Similar Threads

  1. Rpath linking issues in qtcreator
    By Droplet in forum General Programming
    Replies: 1
    Last Post: 7th July 2011, 23:15
  2. Adding glew library
    By Cucus in forum Newbie
    Replies: 3
    Last Post: 20th June 2011, 22:44
  3. Replies: 9
    Last Post: 21st May 2011, 11:54
  4. Linking a foreign static library using QtCreator
    By gib in forum Qt Programming
    Replies: 0
    Last Post: 22nd September 2010, 02:52
  5. Replies: 2
    Last Post: 25th November 2009, 23:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.