Building for XAudio2 with Windows 7

Hello! I am trying to make a spatialization plugin for UE 4.8.

However, when I try to build my plugin module with the following dependencies:

#include "AudioDevice.h"
#include "XAudio2Device.h"
#include "AudioEffect.h"
#include "XAudio2Effects.h"
#include "Engine.h"

#include "AllowWindowsPlatformTypes.h"
#include <xapobase.h>
#include <xapofx.h>
#include <xaudio2fx.h>
#include "HideWindowsPlatformTypes.h"

I trigger the following error in xaudio.h in the Windows 8.1 SDK:

“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.” C:\Program Files
(x86)\Windows
Kits\8.1\include\um\xaudio2.h

This makes sense, since I’m building and running UE4 on a windows 7 machine. How do I instruct the buildtool to include the DirectX version of xaudio.h rather that the Windows 8 native version of XAudio? Thanks!

You can configure include path in build scipts in those arrays:

	PublicIncludePaths.AddRange(
		new string[] {
			"Something/Public"
			
			// ... add public include paths required here ...
		}
		);
			
	
	PrivateIncludePaths.AddRange(
		new string[] {
			"Something/Private"
			
			// ... add other private include paths required here ...
		}
		);

You might alkso check how XAudio module dealing with it:

https://github.com/EpicGames/UnrealEngine/tree/e607ba4d978c08a26e8e8e629dec0884bb161770/Engine/Source/Runtime/Windows/XAudio2

AH! Great suggestion on checking their source: fixed it by adding this to my module’s Build.cs constructor:

AddThirdPartyPrivateStaticDependencies(Target,
            "DX11Audio"
        );

It seems like this will link/ add includes for the DirectX SDK version of the Xaudio2 rather than the Windows 8.1 SDK version.

fixed it by adding this to my module’s Build.cs constructor:

AddThirdPartyPrivateStaticDependencies(Target,
             "DX11Audio"
         );

It seems like this will link/ add includes for the DirectX SDK version of the Xaudio2 rather than the Windows 8.1 SDK version.