Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Can't build OpenGL test code

Can't build OpenGL test code

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ZholamanZ Offline
    ZholamanZ Offline
    Zholaman
    wrote on last edited by Zholaman
    #1

    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'
      etc

    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
    main.cpp
    windows:TARGET = ../OGLQuad

    Thanks

    ZholamanZ 1 Reply Last reply
    0
    • ZholamanZ Zholaman

      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'
        etc

      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
      main.cpp
      windows:TARGET = ../OGLQuad

      Thanks

      ZholamanZ Offline
      ZholamanZ Offline
      Zholaman
      wrote on last edited by
      #2

      @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)

      1 Reply Last reply
      0
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by jsulm
        #3

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

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved