0

So I'm playing around with a DirectX tutorial trying to learn it but i keep getting these errors:

   1>main.obj : error LNK2019: unresolved external symbol _D3D11CreateDeviceAndSwapChain@48
   referenced in function "void __cdecl InitD3D(struct HWND__ *)" (?InitD3D@@YAXPAUHWND__@@@Z)
   1>main.obj : error LNK2019: unresolved external symbol _D3DX11CompileFromFileW@44 referenced in
   function "void __cdecl InitPipeline(void)" (?InitPipeline@@YAXXZ)

Now I am pretty sure this has something to do with including the rigth directories and libs ect. I have added the includes and set the linker options

 #include <d3d11.h>
 #include <d3dx11.h>
 #include <d3dx10.h>
 #pragma comment (lib, "d3d11.lib")
 #pragma comment (lib, "d3dx11.lib")
 #pragma comment (lib, "d3dx10.lib")

I have also set the the directories at configuration properties-> VSC++ directories -> Include directories and Lib. directories

Is there something else I'm missing?

Edit: Im using Visual Studio c++ 2010 express

1 Answers1

0

1) check your linker settings, you need to add your libs there

2) are you building x86 or x64, depending on that the libs are in different folders

3) in vs2010 and before, you need directx sdk installed, comes together with vs2012 sdk

  • 1. to my understanding thats is what the #pragma comment lines does? i have also tryed adding them manually via the linker options 2. i added both 3. i have the sdk installed :) – Fredrik Boston Westman Mar 11 '13 at 17:46
  • The thing is, i was working with this a couple of days ago, and i remebered i got the same error. But then i just added both the x86 and x64 path and it worked, but for some reason it dosnt this time :( i figured i must have done something else last time by mistake to get it to work. Can figure out what tho :( – Fredrik Boston Westman Mar 11 '13 at 17:49
  • oh srry did i forget to say. visual studio c++ 2010 express – Fredrik Boston Westman Mar 11 '13 at 18:06
  • Did you install Directx SDK before or after installing vs2010express? – Richard Peters Mar 11 '13 at 18:10
  • After im pretty sure. But like i said, i have gotten it to work before. I ran in to some other problem and decided to start over. Now it wont work :/ cant figure out what im doing wrong – Fredrik Boston Westman Mar 11 '13 at 18:32
  • generally when you install after vs2010, the sdk configures vs2010 with paths and includes folders and some defines, i m pretty sure its due to conflict of the libs, it detects both version x86 and x64 and cant make up its mind... – Richard Peters Mar 11 '13 at 19:06
  • i Will try reinstall the sdk – Fredrik Boston Westman Mar 11 '13 at 19:10