user3124047
user3124047

Reputation: 301

Direct3D Static Linking

Is there any way to statically link Direct3D so the program doesn't depend on any D3D DLLs? It seems impossible with Direct3D 9 and later (although I would like to be proven wrong), but I can't find any information on older versions. I'm making a small simple game and I really don't want a mandatory installer, but I want to use Direct3D.

Upvotes: -1

Views: 489

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41087

No, there was never a time when you could statically link any version of Direct3D into your app. The same is true for OpenGL.

If what you are asking is "How do I create a Direct3D app that doesn't require an installer?", then this is actually quite easy to achieve as long as you give up on trying to support ancient and irrelevant versions of the Windows OS.

The simplest thing to do is target DirectX 11.0. Your system requirements would read:

Windows 8.1, Windows 8.0, Windows 7, Windows Vista Service Pack 2 with KB 971644

See Direct3D 11 Deployment for Game Developers

  • Use Direct3D 11.0 APIs
  • Use DirectXMath, DirectX Tool Kit, DirectXTex, and/or DirectXMesh which are all statically linked
  • If desired, you could use Effects 11 as it is also statically linked.
  • Avoid all use of D3DX9, D3DX10, and D3DX11
  • Use XInput 9.1.0; avoid XInput 1.3 (on Windows 8.0+ you could use XInput 1.4)
  • Avoid use of XAudio2.7 (On Windows 8.0+ you could use XAudio 2.8)
  • Avoid use of XACT
  • If you use VS 2010 or later, then you can deploy the required VCREDIST files side-by-side with your application with a simple copy
  • If you use the Windows 8.x SDK version of D3DCompile, you can deploy it side-by-side with your application with a simple copy.

Audio is the biggest challenge here since XAudio 2.8 is only on Windows 8.0 or later, and XAudio 2.7 requires the DirectSetup redist to deploy. Most audio middleware solutions use WASAPI directly on Windows Vista+, so these are reasonable options. You could use legacy DirectSound8, and the headers for that are at least in the Windows 8.x SDK that comes with VS 2012/VS 2013.

If you need Windows XP support, then require Windows XP Service Pack 3 as the minimum OS. This will include DirectX 9.0c and WIC components as part of the OS.

  • You'll need to use Direct3D 9 and DirectSound8
  • Avoid using D3DX9 at all so all HLSL shaders would have to be pre-built offline, and you can't use the Effects (FX9) system or D3DXMath.
  • If you are using VS 2012/VS 2013, you can target Windows XP using the *_xp Platform Toolset, but remember that that uses the Windows 7.1A SDK and not the Windows 8.x SDK so it has some implications for DirectX development.
  • Direct3D 9 debugging on Windows 8.0 or later is also a huge pain as there's no developer runtime available for it.

All of this assumes you are using C++. Using .NET is not realistic as the deployment story for .NET is rather complicated. You could in theory use .NET 2.0 if you require Windows Vista+ or later, but it may require enabling a Windows feature on some versions of the OS, and you can't count on any version of .NET to be present on Windows XP. .NET 4.0 is on by default for Windows 8.0+, but support for .NET 3.5 and earlier is off by default. However, all use of DirectX from C# requires additional assemblies which themselves likely have dependencies on the legacy DirectSetup deployment.

Upvotes: 5

Related Questions