C++ 错误C3861:&x27;D3DCompileFromFile';:找不到标识符

C++ 错误C3861:&x27;D3DCompileFromFile';:找不到标识符,c++,visual-studio-2013,direct3d,directx-11,C++,Visual Studio 2013,Direct3d,Directx 11,我正在尝试使用D3D函数D3DCompilFromFile,它工作得非常好,直到我稍微调整了着色器,现在我的程序突然停止识别D3DCompilFromFile函数,我检查了需要包含的头/库/dll,我知道它们都在那里 我正在使用VS2013 下面是一些示例代码 application.cpp HRESULT Application::CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel

我正在尝试使用D3D函数D3DCompilFromFile,它工作得非常好,直到我稍微调整了着色器,现在我的程序突然停止识别D3DCompilFromFile函数,我检查了需要包含的头/库/dll,我知道它们都在那里

我正在使用VS2013

下面是一些示例代码

application.cpp

HRESULT Application::CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut)
{
    HRESULT hr = S_OK;

    DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined(DEBUG) || defined(_DEBUG)
    // Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
    // Setting this flag improves the shader debugging experience, but still allows 
    // the shaders to be optimized and to run exactly the way they will run in 
    // the release configuration of this program.
    dwShaderFlags |= D3DCOMPILE_DEBUG;
#endif

    ID3DBlob* pErrorBlob;
    hr = D3DCompileFromFile(szFileName, nullptr, nullptr, szEntryPoint, szShaderModel,
        dwShaderFlags, 0, ppBlobOut, &pErrorBlob);

    if (FAILED(hr))
    {
        if (pErrorBlob != nullptr)
            OutputDebugStringA((char*)pErrorBlob->GetBufferPointer());

        if (pErrorBlob) pErrorBlob->Release();

        return hr;
    }

    if (pErrorBlob) pErrorBlob->Release();

    return S_OK;
}
应用程序.h

#include <windows.h>
#include <d3d11_1.h>
#include <d3dcompiler.h>
#include <directxmath.h>
#include <directxcolors.h>
#include "resource.h"
#include <iostream>
#include <vector>
#include <time.h>
#include <stdio.h>
#include <stdlib.h> 

using namespace DirectX;
using namespace std;
.
.
.
.
HRESULT CompileShaderFromFile(WCHAR* szFileName, LPCSTR szEntryPoint, LPCSTR szShaderModel, ID3DBlob** ppBlobOut);
对不起,如果我只是对人们扔了太多的代码,但我真的很难找出原因,你在使用吗
D3DCompileFromFile
在旧版本的#43中不存在,这意味着您可能在DirectX SDK中选择了旧版本的“d3dcompiler.h”标头,而不是VS 2013附带的较新Windows 8.1 SDK版本的“d3dcompiler.h”

理想情况下,您根本不应该使用DirectX SDK(请参阅)


我从你的着色器中看到你正在使用Effects 11,所以你应该确保移动到不需要任何DXSDK头的最新版本。请注意,对“fx_5_0”配置文件的支持已被弃用,预计将在HLSL编译器的未来更新中删除。Windows 8.1 SDK 47版本的编译器将发出警告,说明这一点,但仍将编译这些着色器。

感谢您的评论,当我转到D3DCompileFromFile的定义时,它会将我带到位于“Windows Kits\8.1\Include\um”中的d3dcompiler.h文件,该文件还包含
\define d3dcompiler\u DLL\W L“d3dcompiler_47.dll”#定义d3dcompiler_dll_A“d3dcompiler_47.dll”
,这让我相信我使用的是正确的编译器文件,在Include和Lib路径中,我还使用windows 8.1“Include/um”和“Lib\winv6.3\um\x86”“啊,等等,我想我在VC++目录选项卡中留下了原始的包含路径,现在我已经删除了它们,我得到一个错误,说我没有D3DCOMPILER_46.dll#46是VS 2012附带的Windows 8.0 SDK。您的VC++目录选项卡应为默认值(如果设置为其他任何内容,则将它们全部设置为“从父目录继承…”)。如果您还需要来自传统DirectX SDK的内容(基本上是D3DX或XACT),那么您需要将可执行文件设置为
$(ExecutablePath)$(DXSDK_DIR)Utilities\bin\x86
$(ExecutablePath)$(DXSDK_DIR)Utilities\bin\x64$(DXSDK_DIR)Utilities\bin\x86
,包含到
$(IncludePath)$(DXSDK_DIR)包括
,以及库到$(LibraryPath)$(DXSDK_DIR)Lib\x86或
$(LibraryPath)$(DXSDK_DIR)Lib\x64
用于VS 2012或VS 2013。我尝试将它们全部设置为“从父级继承”,但我仍然遇到问题,当我转到D3DCompileFromFile的定义时,它说有两个定义/d3dcompiler.h文件,一个在8.0文件夹中,另一个在8.1文件夹中,现在我只需要找出如何只包含8.1文件夹,我试着告诉它单独包含它,但它似乎没有帮助解决它!在我将8.0文件夹重命名为其他文件夹后,它似乎运行得非常好,然后再次运行该程序,甚至在我将8.0文件夹恢复为其原始名称后,它仍然可以工作。谢谢!
cbuffer cbData
{
    float4x4 World; 
    float4x4 View; 
    float4x4 Projection;

    float4 gDiffuseMtrl; 
    float4 gDiffuseLight; 
    float3 gLightVecW;
    float4 gAmbientMtrl;
    float4 gAmbientLight;
};

struct VS_IN
{
    float4 posL   : POSITION;
    float3 normalL : NORMAL;
};

struct VS_OUT
{
    float4 Pos    : SV_POSITION;
    float4 Col    : COLOR;
};

VS_OUT VS(VS_IN vIn)
{
    VS_OUT output = (VS_OUT)0;

    output.Pos = mul( vIn.posL, World ); 
    output.Pos = mul( output.Pos, View ); 
    output.Pos = mul( output.Pos, Projection );


    // Convert from local to world normal
    float3 normalW = mul(float4(vIn.normalL, 0.0f), World).xyz;
    normalW = normalize(normalW);

    // Compute Colour
    float s = max(dot(gLightVecW, normalW), 0.0f);
    float3 diffuse = s*(gDiffuseMtrl*gDiffuseLight).rgb;
    float3 ambient = gAmbientMtrl * gAmbientLight;
    output.Col.rgb = diffuse + ambient;
    output.Col.a = gDiffuseMtrl.a;


    return output;
}

float4 PS(VS_OUT pIn) : SV_Target
{
    return pIn.Col;
}

technique11 Render
{
    pass P0
    {
        SetVertexShader( CompileShader( vs_4_0, VS() ) ); SetGeometryShader( NULL );
        SetPixelShader( CompileShader( ps_4_0, PS() ) );
    }
}