问题
1>------ Build started: Project: Setup, Configuration: Debug Win32 ------
1>BoxDemo.obj : error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory@24 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
1>C:\Users\Josh\Documents\Game Institute\DirectX\Chapter 1\Projects\Setup\Debug\Setup.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm using VS2012 and trying to setup DX11 using a sample program from Frank D Lunas DX11 book. I have no idea what this error message means, any help would be appreciated.
1>------ Build started: Project: Setup, Configuration: Debug Win32 ------
1>Effects11d.lib(EffectAPI.obj) : error LNK2019: unresolved external symbol _D3DCompileFromFile@36 referenced in function _D3DX11CompileEffectFromFile
1>C:\Users\Josh\Documents\Game Institute\DirectX\Chapter 1\Projects\Setup\Debug\Setup.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
回答1:
Linker cannot find definition of D3DX11CreateEffectFromMemory function. This function is a part of Effects11 framework. And you need to link Effects11.lib
to build this program.
Previously, to develop DirectX apps, you must have been DirectX SDK installed. Now that stand-alone DirectX SDK concerned legacy and now it is a part of Windows SDK (since version 8.0). You`ve got it when installed Visual Studio 2012.
The problem is now this SDK version doesn't include Effect11 framework, among other things.
There are several ways to fix this problems:
- Download and install legacy DirectX SDK. When compiling you will get some warnings, because of conflicting old DirectX SDK and new Windows SDK. To solve this you can switch to your project to
v110xp
toolset or install Windows 7 SDK and switch tov100
in project's options. - In case of this sample program, Mr. Luna included compiled libs in
Common
folder of source code archive. But I'm not sure if it will work with Win8 SDK. - Correct source code and strip out Effect11 stuff. If you just learning DirectX, it is not easy way.
Some more explanation from Chuck Walbourn - MSFT:
- Where is the DirectX SDK?
- Effects for Direct3D 11 Update
来源:https://stackoverflow.com/questions/16642989/dx11-unresolved-externals