Switch from Linux to Windows with Qt6, CMake build system result in linkage error for __imp_glDrawArray
-
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
-
@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 )
-
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)