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. CLion + Qt + OpenGL
QtWS25 Last Chance

CLion + Qt + OpenGL

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 1.2k 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.
  • L Offline
    L Offline
    LgtLeb
    wrote on 9 Apr 2020, 13:55 last edited by
    #1

    Good afternoon,
    I have been recently coding a project including OpenGl which compiles very well on Qt Creator.

    I have been coding on CLion all the way though and been messing up a lot trying to configure my CMakeLists. The problem seems to occur on linking the OpenGL libraries from Qt to the executable.

    cmake_minimum_required(VERSION 3.15)
    project(Toupies_DL)
    
    ADD_DEFINITIONS(-std=c++14 )
    
    set(CMAKE_CXX_STANDARD 14)
    
    
    find_package(Qt5 COMPONENTS OpenGL Widgets Core Gui Multimedia REQUIRED)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTORCC ON)
    
    set(QT_USE_QTOPENGL TRUE)
    
    add_definitions(${QT_DEFINITIONS})
    
    INCLUDE_DIRECTORIES(${QT_QTOPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} )
    
    
    [...]
    
    
    add_executable(ex5
            ${QtFILES}
            ex_05/Qt_GL/main_qt_gl.cc)
    
    qt5_use_modules(ex5 Widgets OpenGL)
    target_link_libraries(ex5 ${QT_LIBRARIES} ${OPENGL_LIBRARIES})
    
    target_link_libraries(ex5 Qt5::Widgets Qt5::Core Qt5::OpenGL Qt5::Gui Qt5::Multimedia)
    

    The project builds correctly but when linking, it returns this error message :

    CMakeFiles\ex5.dir/objects.a(glwidget.cc.obj): In function `ZN8GLWidget8resizeGLEii':
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/glwidget.cc:20: undefined reference to `_imp__glViewport@16'
    CMakeFiles\ex5.dir/objects.a(glwidget.cc.obj): In function `ZN8GLWidget7paintGLEv':
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/glwidget.cc:39: undefined reference to `_imp__glClear@4'
    CMakeFiles\ex5.dir/objects.a(vue_opengl.cc.obj): In function `ZN9VueOpenGL4initEv':
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/vue_opengl.cc:83: undefined reference to `_imp__glEnable@4'
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/vue_opengl.cc:84: undefined reference to `_imp__glEnable@4'
    CMakeFiles\ex5.dir/objects.a(vue_opengl.cc.obj): In function `ZN9VueOpenGL11dessineCubeERK10QMatrix4x4':
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/vue_opengl.cc:125: undefined reference to `_imp__glBegin@4'
    C:/Users/lgtle/Desktop/C++/programmes/projet/Toupies-DL/Toupies-DL/ex_05/Qt_GL/vue_opengl.cc:168: undefined reference to `_imp__glEnd@0'
    collect2.exe: error: ld returned 1 exit status
    
    

    It looks like Clion doesn't find the function of QtOpengl.
    Thank you in advance for your help!

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 9 Apr 2020, 13:59 last edited by
      #2

      This has nothing to do with CLion - you use OPENGL_LIBRARIES but do not search for OpenGL in the first place.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • L Offline
        L Offline
        LgtLeb
        wrote on 9 Apr 2020, 21:34 last edited by
        #3

        Thanks a lot for the answer!
        I still don't see what to change though. Does it have anything to do with the CMakeLists?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 10 Apr 2020, 15:54 last edited by Christian Ehrlicher 4 Oct 2020, 15:54
          #4

          @Christian-Ehrlicher said in CLion + Qt + OpenGL:

          OPENGL_LIBRARIES

          Where do you think is this variable gets defined? You have to search for OpenGL first with FIND_PACKAGE(OpenGL)

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          L 1 Reply Last reply 11 Apr 2020, 14:52
          0
          • C Christian Ehrlicher
            10 Apr 2020, 15:54

            @Christian-Ehrlicher said in CLion + Qt + OpenGL:

            OPENGL_LIBRARIES

            Where do you think is this variable gets defined? You have to search for OpenGL first with FIND_PACKAGE(OpenGL)

            L Offline
            L Offline
            LgtLeb
            wrote on 11 Apr 2020, 14:52 last edited by
            #5

            Thanks a million! It is my first try with Qt, and now I see how dumb was my question, sorry for that.
            Now it works better but it says "undefined reference to `qt_static_plugin_QWindowsIntegrationPlugin()'". I will keep digging. Thanks again !

            1 Reply Last reply
            0
            • C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 11 Apr 2020, 15:03 last edited by
              #6

              Are you using a static Qt?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              L 1 Reply Last reply 11 Apr 2020, 15:54
              0
              • C Christian Ehrlicher
                11 Apr 2020, 15:03

                Are you using a static Qt?

                L Offline
                L Offline
                LgtLeb
                wrote on 11 Apr 2020, 15:54 last edited by
                #7

                @Christian-Ehrlicher No, but I am working on windows, and therefore had to copy all dll's I needed in the cmake-build-debug to make it work. maybe have I forgotten one

                C 1 Reply Last reply 11 Apr 2020, 16:49
                0
                • L LgtLeb
                  11 Apr 2020, 15:54

                  @Christian-Ehrlicher No, but I am working on windows, and therefore had to copy all dll's I needed in the cmake-build-debug to make it work. maybe have I forgotten one

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 11 Apr 2020, 16:49 last edited by
                  #8

                  @LgtLeb said in CLion + Qt + OpenGL:

                  and therefore had to copy all dll's I needed

                  If your setup is correct you don't have to copy any dlls anywhere.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0

                  3/8

                  9 Apr 2020, 21:34

                  topic:navigator.unread, 5
                  • Login

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