GLEW和Qt5标头的重新定义 [英] GLEW and Qt5 redefinition of headers

查看:337
本文介绍了GLEW和Qt5标头的重新定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以

将项目升级到Qt5后,我们遇到了问题.该应用程序链接了需要运行的库,并且在非Qt应用程序中使用库时可以正常运行.

After upgrading our prject to Qt5 we are experiencing issues with glew. The app links a library that needs glew to work, and that works fine when using the library in non Qt apps.

现在,尽管我们将库链接到qt应用程序中,并将其渲染为glwidget.这曾经工作,但现在没有.我们会收到大量错误,这些错误大多说重新定义"某些东西.这里有一些例子:

Now though we are linking the library into a qt app and rendering into a glwidget. This used to work but now it doesnt. We get a huge array of errors that mostly say "redefinition of" something. Here's some examples:

 1>c:\glew-1.9.0\include\gl\glew.h(275): error C2371: 'GLdouble' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\qtgui\qopengl.h(71) : see declaration of 'GLdouble'
1>c:\glew-1.9.0\include\gl\glew.h(630): warning C4005: 'GL_DOUBLE' : macro redefinition
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\qtgui\qopengl.h(68) : see previous definition of 'GL_DOUBLE'
1>c:\glew-1.9.0\include\gl\glew.h(1655): error C2371: 'GLintptr' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(38) : see declaration of 'GLintptr'
1>c:\glew-1.9.0\include\gl\glew.h(1656): error C2371: 'GLsizeiptr' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(39) : see declaration of 'GLsizeiptr'
1>c:\glew-1.9.0\include\gl\glew.h(1707): warning C4005: 'GL_BLEND_EQUATION_RGB' : macro redefinition
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(96) : see previous definition of 'GL_BLEND_EQUATION_RGB'
1>c:\glew-1.9.0\include\gl\glew.h(11533): warning C4005: 'GL_COVERAGE_SAMPLES_NV' : macro redefinition

您明白了.无论如何,我怎样才能阻止Qt包含它的gl内容,以便让glt可以自己工作?

You get the idea. Anyway how can I stop Qt including its gl stuff so glew can work by itself?

如您所见,gles是一个问题,所以我被指示使用此方法:

As you can see gles is being a problem, so I was directed to use this:

#define QT_NO_OPENGL_ES_2

但这根本没有效果.还有其他错误不会引用这些错误:

But this has no effect at all. There are other errors that don't reference gles like these:

    1>c:\glew-1.9.0\include\gl\glew.h(275): error C2371: 'GLdouble' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\qtgui\qopengl.h(71) : see declaration of 'GLdouble'
1>c:\glew-1.9.0\include\gl\glew.h(630): warning C4005: 'GL_DOUBLE' : macro redefinition
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\qtgui\qopengl.h(68) : see previous definition of 'GL_DOUBLE'
1>c:\glew-1.9.0\include\gl\glew.h(1655): error C2371: 'GLintptr' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(38) : see declaration of 'GLintptr'
1>c:\glew-1.9.0\include\gl\glew.h(1656): error C2371: 'GLsizeiptr' : redefinition; different basic types
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(39) : see declaration of 'GLsizeiptr'
1>c:\glew-1.9.0\include\gl\glew.h(1707): warning C4005: 'GL_BLEND_EQUATION_RGB' : macro redefinition
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\gles2\gl2.h(96) : see previous definition of 'GL_BLEND_EQUATION_RGB'
1>c:\glew-1.9.0\include\gl\glew.h(11533): warning C4005: 'GL_COVERAGE_SAMPLES_NV' : macro redefinition
1>          c:\qt\qt5.0.2\5.0.2\msvc2012_64\include\qtgui\qopengles2ext.h(530) : see previous definition of 'GL_COVERAGE_SAMPLES_NV'

希望您能提供帮助!

推荐答案

经过一天的苦苦挣扎,我有一个解决方案!

After a day of screwing around I have a solution!

为了跨平台,Qt似乎已将OpenGLES设置为比桌面openGL更高的优先级.

In order to be cross platform Qt seems to have set OpenGLES to a high priority than desktop openGL.

此问题的解决方案是在构建之前使用设置-opengl desktop从源代码构建Qt.像这样:

THe solution to this is to build Qt from source code suing the setting -opengl desktop before you build. Something like this:

configure -debug-and-release -opengl desktop

然后使用nmake进行构建,效果很好!

Then use nmake to build and it works fine!

这篇关于GLEW和Qt5标头的重新定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆