Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 5.5.0 cannot find OpenGL functions

Tags:

c++

qt

opengl

I have a Qt project that uses OpenGL and compiles fine with Qt 5.4.0. Today I upgraded my Qt to 5.5.0 and my project stopped compiling. It throws a lot of unresolved external symbol errors as you can see here:

link /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:debug\UI.exe @C:\Users\DWilches\AppData\Local\Temp\UI.exe.376.5500.jom
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "private: void __thiscall UIOpenGLVisualizer::PaintScene(void)" (?PaintScene@UIOpenGLVisualizer@@AAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glFrustum@48 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glInitNames@0 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glLineStipple@8 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glLoadName@4 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glPointSize@4 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::initializeGL(void)" (?initializeGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glPushName@4 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glRenderMode@4 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glScalef@12 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glSelectBuffer@8 referenced in function "public: void __thiscall UIOpenGLVisualizer::NewSelectionPerformed(void)" (?NewSelectionPerformed@UIOpenGLVisualizer@@QAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
UIOpenGLVisualizer.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function "public: virtual void __thiscall UIOpenGLVisualizer::paintGL(void)" (?paintGL@UIOpenGLVisualizer@@UAEXXZ)
debug\UI.exe : fatal error LNK1120: 20 unresolved externals
jom: C:\Users\DWilches\Desktop\3DIA\VolumeSelector\VVSIT\build-VVSIT-Desktop_Qt_5_5_0_MSVC2013_32bit-Debug\UI\Makefile.Debug [debug\UI.exe] Error 1120
jom: C:\Users\DWilches\Desktop\3DIA\VolumeSelector\VVSIT\build-VVSIT-Desktop_Qt_5_5_0_MSVC2013_32bit-Debug\UI\Makefile [debug] Error 2
21:35:43: The process "C:\ProgramFiles\Qt\Qt5.5.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project VVSIT (kit: Desktop Qt 5.5.0 MSVC2013 32bit)
When executing step "Make"

I have not modified the .pro files between one and other version of Qt. And my .pro also has the line that says:

QT += opengl

What could be wrong ?

like image 344
Daniel Avatar asked Jul 26 '15 03:07

Daniel


1 Answers

As exposed by @Ben-Voigt in the comments above, I had to explicitly instruct Qt to link against opengl32, so I added the following in my .pro:

LIBS += -lopengl32

I'm not sure why there is a change in behaviour in Qt 5.5.0 as that line was unnecessary in previous versions, but well, it solves the problem.

like image 76
Daniel Avatar answered Oct 08 '22 19:10

Daniel