Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtGui doesn't add linker dependency to libGLESv2



  • I am trying to take the Qt example from examples/gui/openglwindow/ and make it compile/run with CMake. However, when compiling, it fails with a bunch of
    "error LNK2019: unresolved external symbol __imp_glClear"

    I can fix that by manually adding C:\Qt_install\lib\libGLESv2d.lib to the linker path, however, that's obviously not how CMake should work.

    The CMakeLists is very simple:
    @
    PROJECT( oglwin )
    CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 )
    cmake_policy(SET CMP0020 NEW) # for Qt: auto-link to qtmain.lib

    set(CMAKE_AUTOMOC ON)
    find_package(Qt5Core REQUIRED)
    find_package(Qt5Gui REQUIRED)

    SET(SOURCE
    main.cpp
    openglwindow.cpp
    )
    SET(HEADERS
    openglwindow.h
    )
    ADD_EXECUTABLE( oglwin ${SOURCE} ${HEADERS} )
    TARGET_LINK_LIBRARIES( oglwin Qt5::Core Qt5::Gui )
    @

    Now as I mentioned before, my expectation would be that this automatically links to libGLESv2.lib (or libGLESv2d.lib), as I am using a Qt-build built with ANGLE.
    (For that matter, I guess when on the desktop/opengl build, it should link to GL.lib [or whatever the system openGL lib is called]).

    Possibly in my case, it should also link to C:\Qt_install\lib\libEGLd.lib?

    There are a few related topics around, for example this:
    https://bugreports.qt-project.org/browse/QTBUG-29132
    (where it says "fixed"), and one can follow that to gitorious:
    https://codereview.qt-project.org/#change,53857

    Apparently what I'm trying to do should work, but it doesn't. Am I doing something wrong?

    Thank you in advance!


Log in to reply