Reputation: 15705
This is completely driving me insane. When I compile my program, I get the following error message:
error LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48
I know that I have all of the correct lib / and include directories (x86), and I have tracked the problem down to the fact that if I go to the definition (F12) I get two symbols, one for the DirectXSDK install directory, and one at "c:\Program Files (x86)\Windows Kits\8.0\Include\um".
For the life of me, I have no idea what to do. I have gone through all of the include / exclude directories and I can't get it to resolve, and I don't know what to do. Can anyone help me?
Upvotes: 6
Views: 11359
Reputation: 5191
I ran into this error myself and solved it with Luke's suggestion in his comment.
Assuming you're using Visual Studio, try opening the properties window for your project, and navigate to Linker -> Input. Under 'Additional Dependencies' add d3d11.lib
, and try linking again.
Upvotes: 18
Reputation: 3136
Recheck your IDE for libs and make sure your IDE is using Unicode character set and that you're using unicode functions and strings properly. Also, check twice if \lib\x86 (or x64 if its the case), is properly added to your project's libraries.
Upvotes: 0
Reputation: 13003
Okay. Before driving insane, check out that:
you linking against same architecture as your app: x86, x64, arm ( It is common gotcha =) )
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64
C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\arm
you linking lib from the same sdk as your header ( in your source, try type in paths explicitly):
#include "c:\Program Files (x86)\Windows Kits\8.0\Include\um\header.h"
#pragma comment(lib, "C:\\Program Files (x86)\\Windows Kits\\8.0\\Lib\\win8\\um\\x64\\library.lib")
check that libs itself are fine (exist, not corrupted): uninstall old DXSDK and Win8SDK, then reinstall only one of them, try it, than another. (Also it is good idea to just copy somewhere docs and tutorials from old SDK, uninstall it and forget it at all)
try new #pragma linker
(not #pragma lib
) with verbose flag to gain some linker output:
#define USE_OLD_DXSDK
#ifdef USE_OLD_DXSDK
#pragma comment(linker "c:\\path\\to\\old_sdk\\d3d11.lib -verbose")
#else
#pragma comment(linker, "c:\\path\\to\\new_sdk\\d3d11.lib -verbose")
#endif
Go another way: Create a new small app and try to write D3D11CreateDeviceAndSwapChain
stuff from scratch. Only #include
and link
what is needed right now and nothing else. Try to reproduce your linker error to understand why it is happens and find out how to fix it in your main app.
Happy coding!
Upvotes: 8