首页 > 解决方案 > 未找到 Qt 5.12 D3D 编译器模块

问题描述

我已经安装了 Qt 5.12 ,当我想编译我的项目时显示此错误:

错误:

QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
ensureInitialized(141): D3D compiler module not found.
QOpenGLShader::link: D3D compiler module not found.
shader compilation failed: 
"D3D compiler module not found.\n"

标签: c++qtqmlqt5

解决方案


欢迎来到 SO!

首先,让我们澄清一下错误的含义。

Qt 在 Windows 上使用ANGLE,这是一个允许在 OpenGL 不可用的系统上运行 OpenGL 软件的层,方法是将 OpenGL 调用转换为 DirectX 调用。Qt 根据机器的配置(显卡型号、显卡驱动版本等)决定是使用纯 OpenGL 还是 ANGLE。有关这方面的更多详细信息,请访问https://wiki.qt.io/Qt_5_on_Windows_ANGLE_and_OpenGL

即使您自己没有编写任何 OpenGL 代码,qml 运行时肯定也有很多 OpenGL 调用,可能再次通过 ANGLE。

这就是为什么会出现令人困惑的错误消息(在处理 OpenGL 代码时寻找 D3D 着色器编译器!)。

现在,Qt 项目bugtracker报告了与https://bugreports.qt.io/browse/QTBUG-71510相同的问题,尽管在撰写本文时尚未提供解决方案。我建议不时查看 bugtracker 以监控此问题的进展。

您可以尝试几种解决方法:

  1. 将 d3dcompiler_xx.dll 复制到你的 exe 所在的同一目录中;
  2. 通过将环境变量QT_OPENGL设置为桌面,强制 Qt 使用 OpenGL 而不是 DirectX (更多详细信息请参见http://doc.qt.io/qt-5/windows-requirements.html

推荐阅读