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!
-
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()
{}
-
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(...)
@ -
Here is a link to a google drive shared rar file with the whole project:
https://docs.google.com/file/d/0B0z5KZUIEVmXbjZvZkc3SkhtTUk/edit?pli=1In 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.