簡體   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