Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Switch from Linux to Windows with Qt6, CMake build system result in linkage error for __imp_glDrawArray

Switch from Linux to Windows with Qt6, CMake build system result in linkage error for __imp_glDrawArray

Scheduled Pinned Locked Moved Unsolved Game Development
3 Posts 2 Posters 422 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.
  • D Offline
    D Offline
    Dramstragoran
    wrote on 30 Nov 2024, 09:39 last edited by
    #1

    Hi dear Qt users!
    I usually work on Linux, and everything is perfect. But, I also need to compile my project on Windows. Currently, using Visual Studio 2022, and Qt6.8, Vulkan SDK is also installed.

    I'm using CMake, my CMakeLists.txt is looking like

    cmake_minimum_required(VERSION 3.16)
    project(Test LANGUAGES CXX)
    
    SET(CMAKE_MODULE_PATH ${Test_SOURCE_DIR}/cmake)
    
    find_package(Eigen3 REQUIRED)
    include_directories( SYSTEM ${EIGEN3_INCLUDE_DIR} )
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
    
    find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGL OpenGLWidgets)
    add_executable(Test
       main.cpp
       MyCustomTestWidget.cpp
       )
    target_link_libraries(Test PRIVATE Qt6::Widgets Qt6::OpenGL Qt6::OpenGLWidgets)
    target_compile_features(Test  PRIVATE cxx_std_17)
    

    After setting some CMake variable (Qt6_DIR, Qt6CoreTools_DIR and QT6GuiTools_DIR), project is generated as it should with MSVC x64 compiler. However, compilation fails at linking indicating __imp_glDrawArrays is missing.
    Does someone have a solution for this?

    Thank you for reading

    C 1 Reply Last reply 30 Nov 2024, 12:28
    0
    • D Dramstragoran
      30 Nov 2024, 09:39

      Hi dear Qt users!
      I usually work on Linux, and everything is perfect. But, I also need to compile my project on Windows. Currently, using Visual Studio 2022, and Qt6.8, Vulkan SDK is also installed.

      I'm using CMake, my CMakeLists.txt is looking like

      cmake_minimum_required(VERSION 3.16)
      project(Test LANGUAGES CXX)
      
      SET(CMAKE_MODULE_PATH ${Test_SOURCE_DIR}/cmake)
      
      find_package(Eigen3 REQUIRED)
      include_directories( SYSTEM ${EIGEN3_INCLUDE_DIR} )
      
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTOUIC ON)
      
      find_package(Qt6 REQUIRED COMPONENTS Widgets OpenGL OpenGLWidgets)
      add_executable(Test
         main.cpp
         MyCustomTestWidget.cpp
         )
      target_link_libraries(Test PRIVATE Qt6::Widgets Qt6::OpenGL Qt6::OpenGLWidgets)
      target_compile_features(Test  PRIVATE cxx_std_17)
      

      After setting some CMake variable (Qt6_DIR, Qt6CoreTools_DIR and QT6GuiTools_DIR), project is generated as it should with MSVC x64 compiler. However, compilation fails at linking indicating __imp_glDrawArrays is missing.
      Does someone have a solution for this?

      Thank you for reading

      C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 30 Nov 2024, 12:28 last edited by
      #2

      @Dramstragoran said in Switch from Linux to Windows with Qt6, CMake build system result in linkage error for __imp_glDrawArray:

      Does someone have a solution for this?

      Try to link against the opengl libs (opengl32 as you can see in https://learn.microsoft.com/en-us/windows/win32/opengl/gldrawarrays )

      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
      1
      • D Offline
        D Offline
        Dramstragoran
        wrote on 1 Dec 2024, 08:38 last edited by
        #3

        Thank you @Christian-Ehrlicher it worked!
        Could it be considered as a bug? (I would expect the cmake files of Qt to link openGL as I'm using Qt6::OpenGL)

        1 Reply Last reply
        0

        1/3

        30 Nov 2024, 09:39

        • Login

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