QCustomPlot Discussion and Comments

OpenGL QCustomPlot results in unresolved externals?Return to overview

I'm using Qt 5.7 VS2015 and following the documentation for turning on OpenGL. I'm using the QML shim found on these forums.

I've set the define

DEFINES += QCUSTOMPLOT_USE_OPENGL

and clean, qmake, rebuild. However I get unresolved externals.

qcustomplot.obj:-1: error: LNK2019: unresolved external symbol __imp_glClear referenced in function "public: virtual void __cdecl QCPPaintBufferGlFbo::clear(class QColor const &)" (?clear@QCPPaintBufferGlFbo@@UEAAXAEBVQColor@@@Z)

qcustomplot.obj:-1: error: LNK2019: unresolved external symbol __imp_glClearColor referenced in function "public: virtual void __cdecl QCPPaintBufferGlFbo::clear(class QColor const &)" (?clear@QCPPaintBufferGlFbo@@UEAAXAEBVQColor@@@Z)

qcustomplot.h + cpp are included in the project.

Is there a solution?

Found the solution, there was a change to the 2.0 beta a few months ago which replaced Qt wrapped OpenGL calls with raw OpenGL to fix Qt 5.0-5.2. However this broke OpenGL usage on Qt 5.7.

https://gitlab.com/DerManu/QCustomPlot/commit/364c3f42f53f1da8ec79e7985fe5b4c644f4ae2b

Changing this back, and prefixing the other raw GL calls with the following fixed OpenGL on Qt 5.7

mGlContext.data()->functions()->

Thanks for your feedback, I had a similar report recently.

It'll probably end up being a conditional depending on Qt version. Unforunately that's quite inconsistent: on some systems directly calling glClear works fine, in other instances you need to go through QOpenGLFunctions, and again in others (e.g. Qt5.0-5.2) glClear is missing completely from QOpenGLFunctions.

For those coming across this, this solved it for me.

(It worked in profile and release, but not in debug for some reason. Qt 5.8)

your_project.pro
Add:

LIBS += -lOpenGL32