QT 找不到 opengl

Qt 5.5.0 cannot find OpenGL functions

Ask Question up vote 4 down vote favorite 2 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) 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 ?

c++ qt opengl shareimprove this question asked Jul 26 '15 at 3:38

MondKin 4,66711633 1    You need to pass opengl32.lib to link. You're using a response file, so you'll want to put it there instead of the command-line, and I don't know how to use your particular tool to control the response file, but opengl32.lib is the import library where those functions are found. �C Ben Voigt Jul 26 '15 at 3:42       Yes, thanks, I added -lopengl32 and now it works. I wonder why now it is necessary with  this new version of Qt, while before it seemed to be done automatically by: QT += opengl.  Could you add this as an answer ? �C MondKin Jul 26 '15 at 3:48       I have no clue what QT += opengl does or doesn't do in the different versions, so any answer I write wouldn't be very complete. Why don't you write a self-answer showing how/where you added that -lopengl32 to make it play nicely with the Qt build process? �C Ben Voigt Jul 26 '15 at 3:49 add a comment 1 Answer active oldest votes up vote 9 down vote accepted 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.

shareimprove this answer answered Jul 26 '15 at 3:54

MondKin 4,66711633       If I had to guess, there was a hard coded check inside qt to replace opengl with the proper system-specific library, and somehow that got broken in 5.5. However I don't use qt (or opengl) so it's just a guess. I'd report this as a bug on their forums.  �C Blindy Jul 26 '15 at 4:04       @Blindy: There's no such thing as a system specific library, when it comes to OpenGL  (yes I do know, that in Linux the vendor proprietary drivers install their own  libGL.so). The ABIs of the OSs where OpenGL is supported pinned down and any DLL/SO  that follows those ABIs will link at runtime with your program just fine (assuming   the program itself adheres to the ABI as well). �C datenwolf Jul 26 '15 at 7:57       @Blindy: I think something like what you said is what happened, check this: blog.qt.io/blog/2015/07/01/qt-5-5-released , specially: Using OpenGL on Windows has always been somewhat problematic as good drivers are not available in all installations  by default. Qt 5.5 helps solve this problem by switching dynamically between using  the OpenGL driver or the ANGLE emulation layer implementing OpenGL on top of DirectX.   �C MondKin Jul 26 '15 at 17:10       @datenwolf, not sure what your point is -- Linux typically uses libGL, Windows opengl32.lib,  those are system-specific names. Of course you're probably just arguing to hear yourself  speak so you can ignore that. @Mondkin yeah it kinda made sense. That's good, it means   that chances are good it will be fixed in a patch or the next version. �C Blindy Jul 26 '15 at 23:32       @Blindy: Oh, I took your comment as "in Linux every OpenGL driver brings his how libGL.so" and some people mistake that for that programs must be linked to that specific libGL.so or use dlopen/dlsym to resolve the symbols (in ancient times this was indeed the case, but then the LSB pinned down the ABI requirements and ever since this has not been a problem). Anyway, when we're at system specifics, then there's -framework OpenGL on MacOS X; however all of that  should be abstracted away in Qt's qmake (it definitely is in CMake's FindOpenGL.cmake module).   �C datenwolf Jul 27 '15 at 8:10

转载于:https://www.cnblogs.com/Searchor/p/6855457.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值