繁体   English   中英

Windows 10 环境中出现“此版本的 XAudio2 仅在 Windows 8 中可用”错误

[英]"This version of XAudio2 is available only in Windows 8" error in Windows 10 environment

我想在 Windows 10 的 Qt 应用程序中使用 xaudio2 库。我将 Qt creator 4.9.2 作为 IDE 与 MinGW 7.3.0 编译器结合使用。 据我所知,xaudio2 是 Windows SDK 的一部分,从 Win8 开始。 我从该页面获得了最新的 SDK 版本并将其安装在我的工作站上。 我通过在我的 .pro 文件中添加以下行来导入这个库:

INCLUDEPATH += "C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um"
unix|win32: LIBS += -lxaudio2

并在我的来源中包含所需的定义,如下所示:

#include <xaudio2.h>

但是当我尝试编译我的应用程序时出现以下错误:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\xaudio2.h:20: error: #error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
 #error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."

  ^~~~~

我无法理解,为什么编译器不将我的系统识别为 Win10,而是将其识别为 Win7。 我还发现,此 SDK 版本中仅存在 xaudio2_8.lib,但应在 Win10 上使用 AFAIK、xaudio2_9.lib。

有人可以帮我解决这个问题吗?

这是基于_WINNT_WIN32预处理器定义的。

如果你查看 xaudio2.h,你会看到:

#if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
#error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
#endif // (_WIN32_WINNT < _WIN32_WINNT_WIN8)

_WINNT_WIN32定义必须是0x0602 (Windows 8.0)、或0x0603 (Windows 8.1) 或0x0A00 (Windows 10) 以定位 XAudio 2.8/2.9。

请参阅此博客文章Microsoft Docs:使用 Windows 标头

更新:请注意,有一个新包可以将 XAudio 2.9 下级到 Windows 7 SP1 或更高版本。 请参阅Microsoft 文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM