简体   繁体   English

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

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

I want to use xaudio2 library in my Qt application for Windows 10. I use Qt creator 4.9.2 as IDE in conjuction with MinGW 7.3.0 compiler.我想在 Windows 10 的 Qt 应用程序中使用 xaudio2 库。我将 Qt creator 4.9.2 作为 IDE 与 MinGW 7.3.0 编译器结合使用。 As I know xaudio2 is a part of windows SDK, starting from Win8.据我所知,xaudio2 是 Windows SDK 的一部分,从 Win8 开始。 I've got the latest SDK version from this page and installed it on my workstation.我从该页面获得了最新的 SDK 版本并将其安装在我的工作站上。 I import this library, by adding this lines in my .pro file:我通过在我的 .pro 文件中添加以下行来导入这个库:

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

And also include the needed definitions in my sources like this:并在我的来源中包含所需的定义,如下所示:

#include <xaudio2.h>

But when I try to compile my app the following error appears:但是当我尝试编译我的应用程序时出现以下错误:

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."

  ^~~~~

I couldn't understand, why compiler doesn't identify my system as Win10, but rather Win7 instead.我无法理解,为什么编译器不将我的系统识别为 Win10,而是将其识别为 Win7。 Also I've figured out, that only xaudio2_8.lib is present in this SDK release, but AFAIK, xaudio2_9.lib should be used on Win10.我还发现,此 SDK 版本中仅存在 xaudio2_8.lib,但应在 Win10 上使用 AFAIK、xaudio2_9.lib。

Can anybody help me to solve this problem?有人可以帮我解决这个问题吗?

This is based on the _WINNT_WIN32 preprocessor define.这是基于_WINNT_WIN32预处理器定义的。

If you look in xaudio2.h, you'd see:如果你查看 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)

The _WINNT_WIN32 define has to be 0x0602 (Windows 8.0), or 0x0603 (Windows 8.1), or 0x0A00 (Windows 10) to target XAudio 2.8/2.9. _WINNT_WIN32定义必须是0x0602 (Windows 8.0)、或0x0603 (Windows 8.1) 或0x0A00 (Windows 10) 以定位 XAudio 2.8/2.9。

See this blog post and Microsoft Docs: Using the Windows Headers .请参阅此博客文章Microsoft Docs:使用 Windows 标头

UPDATE: Note there is a new package to get XAudio 2.9 down-level to Windows 7 SP1 or later.更新:请注意,有一个新包可以将 XAudio 2.9 下级到 Windows 7 SP1 或更高版本。 See Microsoft Docs .请参阅Microsoft 文档

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

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