QAbstractOpenGLFunctions, QOpenGLFunctions_2_0 linker errors



  • Hi, I've recently attempted to switch to 5.1, and use the QAbstractOpenGLFunctions method of getting OpenGL extensions. I'm trying out QOpenGLFunctions_2_0 for now, just to start off, and everything compiles fine. I'm trying to build a 32-bit app in MSVC 2012 on windows 7.

    The problem is the linker throws an error for every single QOpenGLFunctions_2_0 function I attempt to use. I've tried including every single debug .lib file I could, and still get the linker error. What .lib should I have/link against to make this work?

    Thanks!



  • Hi, hmm this sounds weird. Can you paste the exact output please? Also maybe post the relevant piece of code too.

    Thanks



  • Sorry for the late reply, I was not in the office during the weekend.

    I recreated this issue by starting a new project using the new QT project interface in VS2012. Here is the error:

    test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QOpenGLFunctions_2_0::glUniformMatrix4fv(int,int,unsigned char,float const *)" (_imp?glUniformMatrix4fv@QOpenGLFunctions_2_0@@QAEXHHEPBM@Z) referenced in function "public: __thiscall test::test(class QWidget *)" (??0test@@QAE@PAVQWidget@@@Z)

    Here is the relevant piece of code (it does nothing, just demonstrates the problem):
    #include "test.h"

    #undef QT_OPENGL_ES_2
    #include <qopenglfunctions_2_0>

    test::test(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);

    QOpenGLFunctions_2_0* Func = dynamic_cast<QOpenGLFunctions_2_0*>(QOpenGLContext::currentContext()->versionFunctions());
    Func->glUniformMatrix4fv(0, 0, false, NULL);

    }

    test::~test()
    {

    }


  • Lifetime Qt Champion

    Hi,

    Looking at the "QOpenGLFunctions":http://qt-project.org/doc/qt-5.0/qtgui/qopenglfunctions.html documentation, it seems that you are not using QOpenGLFunctions the correct way. There might be the problem



  • All of the QOpenGLFunctions_<MAJOR>_<MINOR>[_PROFILE] classes are part of the QtGui library. Are you sure you are linking to QtGui?

    To obtain and initialise the functions object I usually use code like this:

    In class declaration:
    @
    QOpenGLFunctions_2_0* m_funcs;
    @

    In implementation, typically in some init function:
    @
    // Assumign you have a current QOpenGLContext
    m_funcs = m_context->versionFunctions<QOpenGLFunctions_2_0>()
    if (!m_funcs)
    qFatal("Could not obtain OpenGL 2.0 functions");
    m_funcs->initializeOpenGLFunctions();

    // Then use it
    m_funcs->glUniformMatrix4fv(...)
    @



  • Yes, I double checked just now and I was indeed linking against QtGui. Also to be sure I tried linking against every .lib in the bin directory, and the error persists. My QT context is a downloaded 5.1.0 binary for windows 7, x86, msvc2012.



  • Can you post a small compilable example that I can use to try to reproduce the problem please?



  • Here is a link to a google drive shared rar file with the whole project:
    https://docs.google.com/file/d/0B0z5KZUIEVmXbjZvZkc3SkhtTUk/edit?pli=1

    In this case, I've set the project file to point to the downloaded binary version of QT (qt-windows-opensource-5.1.0-msvc2012-x86-offline.exe) I installed. I've also been compiling various QT versions, and found that when I compile QT myself, this problem disappears, so I can just use that for now if this is a low priority problem.



  • Ah I think I see the issue. I think you are using a version of Qt compiled against ANGLE which only provides OpenGL ES 2 compatibility rather than full OpenGL.

    Please try one of the pre-compiled packages that has "opengl" in the filename.



  • Thanks, that solved my issue.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.