Building with XAudio2 on Windows 7
Asked Answered
D

2

5

I'm trying to use the following instructions to build some code that uses XAudio2 and runs on Windows 7:

http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275%28v=vs.85%29.aspx

As suggested, I'm including the XAudio2.h from the DirectX SDK:

#include <%DXSDK_DIR%Include\xaudio2.h>

Result:

fatal error C1083: Cannot open include file: '%DXSDK_DIR%Include\xaudio2.h': No such file or directory

Oh well. I was pretty sure VC++ didn't expand environment variables like that anyway. So I replaced the #include with one that included it directly:

#include <C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include/XAudio2.h>

(Some other instructions, that also suggest using the full path, can be found here: http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx)

Result:

c:\program files (x86)\microsoft directx sdk (june 2010)\include\xaudio2.h(20): fatal error C1083: Cannot open include file: 'comdecl.h': No such file or directory

Sure enough, that file includes comdecl.h using angle brackets, directing VC++ to look outside the current folder.

I added the DirectX SDK include folder ($(DXSDK_DIR)/include) to the project #include search path then, leaving the #include as it was, and:

c:\program files (x86)\microsoft directx sdk (june 2010)\include\dxgitype.h(12): warning C4005: 'DXGI_STATUS_OCCLUDED' : macro redefinition
       c:\program files (x86)\windows kits\8.0\include\shared\winerror.h(49449) : see previous definition of 'DXGI_STATUS_OCCLUDED'

(...ad infinitum)

(my project includes the DirectX headers as well.)

Same result if I added the DirectX SDK include folders to the other end of the search path list.

Has anybody managed to get any of this to work while following these (or any other) instructions?

Dufresne answered 13/6, 2013 at 21:54 Comment(4)
How did you fix your issue?Canikin
@MurhafSousli I gave up on XAudio2.Dufresne
I fixed it by installing DirectX SDK 2010 (Win 10)Canikin
FYI, there's now a way to use the latest XAudio 2.9 on Windows 7. See Microsoft Docs.Measured
S
0

The XAudio2 API is now a system component in Windows 8. The headers and libraries for XAudio2 are available in the Windows SDK.

Well, the problem is that you mixing old headers from DirectX SDK and new from Win8 SDK which was not intended to use together.

Most times

warning C4005: macro redefinition

means that your code compiles and run well. But to prevent possible errors in future, you must use one of the:

  • Windows 8 SDK v110_xp toolset (Project Properties -> General -> Platform Toolset) and old DirectX SDK. There are some drawbacks: read in the bottom here
  • Windows 7 SDK v100 toolset and old DirectX SDK. You need to install Windows 7 SDK.
  • Only Windows 8 SDK v110 platform toolset.
  • Dig into headers, isolate and strip XAudio2 stuff and make it possible to use independly from any of SDKs. But this is not quite good idea =)

Edit: I edited my answer, because I found that XAudio is still not obsolete =)

Slemmer answered 14/6, 2013 at 11:2 Comment(3)
I'm somewhat sure that mixing and matching the headers isn't supposed to be a problem, because that's exactly what the documentation seems to be saying that one has to do.Dufresne
@Tom Seddon Where in this docs you found that you must mix Win 8 SDK's (which is included in VS2012 installation) headers and DirectX SDK? Visual studio disagreed on this too. So, why don't you use just Windows 8 SDK and XAudio from it? You can develop on Windows 7 with newer kit (3rd option in my answer).Slemmer
Well, there are two links in my post suggesting exactly this, and if you include the XAudio2 header from the Windows 8 SDK with _WIN32_WINNT set to the Windows 7 setting, it tells you to use the DirectX headers. (Perhaps "documentation" is taking it too far - I apologise for the slack terminology.) Anyway, I am starting to feel like this is not going to have a happy ending - this reminds me of audio on Linux ;) - so I've given up on XAudio 2.Dufresne
H
0

Hey sorry I know I'm late on this but this article

https://directxtk.codeplex.com/wikipage?title=Adding%20the%20DirectX%20Tool%20Kit%20for%20Audio

details how you need to include the legacy includes and libs. One thing to note, as I understand it after including these directories you will then have dependencies on the Microsoft DirectX SDK (June 2010) directory which windows 8 and 10 don't have. This means when you go to package up your project you should include/run the legacy directx redist for installation on newer machines.

You've probably already solved this issue but hopefully anyone else who finds this will see this. Hope it helps!

Haihaida answered 13/4, 2016 at 15:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.