我有代码:
#include <windows.h>
#include <detours.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dcompiler.h>
#include <xnamath.h>
#include <sstream>
#pragma comment(lib, "detours.lib")
BOOL (WINAPI * TrueSetWindowText)(HWND hWnd, LPCTSTR lpString) = SetWindowText;
TrueSetWindowText指向winapi函数SetWindowText的指针。接下来我用它一切正常。
我决定尝试Direct3D功能。添加:
HRESULT (WINAPI * TrueD3DX11CreateShaderResourceViewFromFile)(
ID3D11Device *pDevice,
LPCTSTR pSrcFile,
D3DX11_IMAGE_LOAD_INFO *pLoadInfo,
ID3DX11ThreadPump *pPump,
ID3D11ShaderResourceView **ppShaderResourceView,
HRESULT *pHResult) = D3DX11CreateShaderResourceViewFromFile;
指向D3DX11CreateShaderResourceViewFromFile的指针。当我编译项目时,我收到一个错误。
dllmain.obj : error LNK2001: unresolved external symbol _D3DX11CreateShaderResourceViewFromFileW@24
fatal error LNK1120: 1 unresolved externals
在项目属性中,我添加了VC + +目录:
包括目录C:\ Program Files%28x86%29 \ Microsoft DirectX SDK%28June 2010%29 \包含
Lib Dirs C:\ Program Files%28x86%29 \ Microsoft DirectX SDK%28June 2010%29 \ Lib \ x86
有没有人知道为什么会出现这个错误?