c – Qt 5.5.0找不到OpenGL函数

前端之家收集整理的这篇文章主要介绍了c – Qt 5.5.0找不到OpenGL函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个使用OpenGL的Qt项目,并使用Qt 5.4.0进行编译.今天我将Qt升级到5.5.0,我的项目停止编译.它会抛出许多未解决的外部符号错误,如下所示:
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"

我没有在一个和其他版本的Qt之间修改.pro文件.我的.pro也有这样的说法:

QT += opengl

可能有什么不对?

解决方法

正如@ Ben-Voigt在上面的评论中所揭示的那样,我必须明确指示Qt链接到opengl32,所以我在.pro中添加了以下内容
LIBS += -lopengl32

我不确定为什么Qt 5.5.0中的行为发生了变化,因为在以前的版本中该行是不必要的,但是,它解决了这个问题.

猜你在找的C&C++相关文章