我正在尝试在我的C ++项目中使用DirectX 11但是当我编译时出现错误说:
D3D11 ERROR: D3D11 header version mismatch.
The application was compiled against and will only work with D3D11_SDK_VERSION (1), but the currently installed runtime is version (7).
Recompile the application against the appropriate SDK for the installed runtime.
我不知道造成这种情况的原因。有没有办法切换它尝试编译的运行时?我从2010年6月开始安装DirectX SDK。我尝试按照微软的说明(http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275(v=vs.85).aspx)来确保使用DirectX正确设置了一些东西。我仍然得到这个错误。有没有人知道可能导致这种情况的原因以及如何解决这个问题?我正在使用Windows 8 64位和Visual Studio 2012。
供参考
我把它作为一个空的C ++解决方案启动,而不是作为DirectX应用程序。以下是我的代码处理DirectX的部分
#include <amp.h>
#include <amp_math.h>
#include <amp_graphics.h>
#include <d3d11.h>
#include <dxgi.h>
#pragma comment(lib, "d3d11")
#pragma comment(lib, "dxgi")
// Inside main()
IDXGIAdapter* pAdapter = nullptr; // Use default adapter
unsigned int createDeviceFlags = D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
ID3D11Device *pDevice = nullptr;
ID3D11DeviceContext *pContext = nullptr;
D3D_FEATURE_LEVEL featureLevel;
HRESULT hr = D3D11CreateDevice(pAdapter,
D3D_DRIVER_TYPE_UNKNOWN,
NULL,
createDeviceFlags,
NULL,
0,
D3D11_SDK_LAYERS_VERSION,
&pDevice,
&featureLevel,
&pContext);
if(FAILED(hr) ||
((featureLevel != D3D_FEATURE_LEVEL_11_1) &&
(featureLevel != D3D_FEATURE_LEVEL_11_0)))
{
std::wcerr << "Failed to create Direct3D 11 device" << std::endl;
return 10;
}