Can't build OpenGL test code

  • Hi, please help.

    Every time when I build the source code I get the following errors:

    • D:\c++_project\build-OGLQuad-Desktop_Qt_5_5_1_MinGW_32bit-Debug\debug\OGLQuad.o:-1: In function `ZN7OGLQuad8resizeGLEii':
    • D:\c++_project\test9\OGLQuad.cpp:37: error: undefined reference to `_imp__glMatrixMode@4'
    • D:\c++_project\test9\OGLQuad.cpp:38: error: undefined reference to `_imp__glLoadIdentity@0'
    • D:\c++_project\test9\OGLQuad.cpp:39: error: undefined reference to `_imp__glViewport@16'
    • D:\c++_project\test9\OGLQuad.cpp:40: error: undefined reference to `_imp__glOrtho@48'
    • D:\c++_project\test9\OGLQuad.cpp:46: error: undefined reference to `_imp__glClear@4'
    • D:\c++_project\test9\OGLQuad.cpp:48: error: undefined reference to `_imp__glBegin@4'

    I use Qt 5.5.1, Qt Creator 3.6, MinGW 4.9.3 (32bit)

    My environment:
    OS Windows 7, 64bit.

    Source code of my project:

    pro file.
    TEMPLATE = app
    QT += widgets opengl core gui
    HEADERS = OGLQuad.h
    SOURCES = OGLQuad.cpp
    windows:TARGET = ../OGLQuad


  • @Zholaman For those who faced with this problem.

    I have resolved it by adding the following lib in my pro file:

    LIBS += -LD:\Qt\5.5\mingw492_32\lib\libQt5OpenGL.a -lopengl32

    The D:\Qt\5.5\mingw492_32\lib\libQt5OpenGL.a is path to lib file (libQt5OpenGL.a)

  • Lifetime Qt Champion

    -LD:\Qt\5.5\mingw492_32\lib\libQt5OpenGL.a - is wrong.
    -L option is used to specify directories where the linker should look for libraries. You're specifying a file.
    It should not be required to specify the path to libQt5OpenGL.a as it is part of Qt - QT += opengl should be enough.
    The errors you get are not related to libQt5OpenGL.a, I think they are related to missing opengl32. So, adding -lopengl32 should be sufficient.

Log in to reply