10

I'm using Windows 8 / Visual Studio 2012, C++11 and Direct3D 11 for development.

I include the Direct3D libraries like this

#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "d3dx11.lib") // <-- error LNK1104: cannot open file 'd3dx11.lib'
#pragma comment(lib, "d3dx10.lib")

However, the linker can't seem to find the d3dx11.lib. After adding the path where the library is located to the 'Library directories' of the project, the linker still can't find those files. Even after I copied the lib files into the project directory itself, it doesn't work.

I installed the Windows 8 SDK as well as the DirectX SDK from June 2010. Am I missing anything?

bytecode77
  • 14,163
  • 30
  • 110
  • 141
  • Are you sure the "D3DX11" lib file is included with those you're copying? I suppose you can link it in, but the D3DX utility library is no longer supported - in fact you don't need to download the 2010 SDK at all. D3DX has been replaced with the DirectXMath library (XMMath). The conversion is a bit of a pain, but not too bad. – Mark Stevens Mar 29 '13 at 19:01
  • Ok. Didn't knew that. I'm pretty new to D3D11. I will see how to do it without this lib. – bytecode77 Mar 29 '13 at 20:26
  • Sometimes D3DX is the way to go (I don't use DirectXMath because it complicates interop with CUDA). Also, some interfaces for DirectXMath are poor for porting (e.g. initialization). Did you find a fix? (A way of sticking with Windows SDK and neatly accessing D3DX?) – axon Dec 09 '14 at 04:35
  • You DO have to link D3DX if you want windows 7 to work – Epirocks Nov 30 '16 at 10:51

3 Answers3

9

When dealing with this myself, I started here:

Where is the DirectX SDK?

then - in about the middle of that page, reading about DirectXMath:

DirectXMath

It's pretty much just including the right header files and changing "D3DX" prefixes to "XM". Not quite that simple, but that's the general idea.

Your first program will probably have inclusions/usings like this:

#include <d3d11.h>
#include “DirectXMath.h”
#include “DirectXPackedVector.h”

using namespace DirectX; 
using namespace DirectX::PackedVector;

struct mystruct
{
   DirectX::XMFLOAT3 position;
   DirectX::PackedVector::HALF packedValue;
};

Of course, it's not considered best practice to have "using namespace", but in this one instance I found that "DirectX::" on every line of my program was making my program almost impossible (for me) to read - so I went with the "using".

Good luck!

Mark Stevens
  • 2,366
  • 14
  • 9
  • It says DirectXMath is for Windows 8 or later. Is there something which can also be used for Windows Vsta/7? – bytecode77 Mar 30 '13 at 15:32
  • Also, I haven't found any tutorials which doesn't use d3dx. Can you point me to one that doesn't use this depricated library? – bytecode77 Mar 30 '13 at 15:36
  • I've used it with Win7 with no troubles. The only tutorial I could find was MS's (http://code.msdn.microsoft.com/windowsdesktop/Direct3D-Tutorial-Win32-829979ef) and that was good enough to get me going. If you really don't want to use XM, of course you should be able to link in D3DX11.lib and DX10 support, etc (as in your OP). But since you're just starting out, might as well be using current libraries. – Mark Stevens Mar 30 '13 at 19:06
  • This really looks like a nice place to start. Thanks! – bytecode77 Mar 30 '13 at 19:44
  • So DirectXMath replaces the need for d3dx10 and 11? –  Apr 03 '13 at 14:41
  • Yes. It is 'optimized' for available HW so in theory it's 'better'. Porting a D3DX app to DirectXMath for me was mostly just changing names. For example, "D3DXMatrixLookAt" becomes "XMMatrixLookAt", D3DXMATRIX" becomes "XMMATRIX", etc. *BUT* there are some notable differences. For one, XMVECTOR doesn't overload the assignment operator, so instead of "XMVECTOR vec = XMVECTOR(1,2,3)", you need to call the "set" method: "XMVECTOR vec = XMVectorSet(1,2,3);" – Mark Stevens Apr 03 '13 at 18:14
  • It only considered a bad practice to put a "using namespace" in a header file. – Henry Bennett Dec 31 '14 at 03:00
1

Probably you included bad path in properties, Instead "*DirectxSDK/Lib/x86", you included ""*DirectxSDK/Lib".

KubenQPL
  • 113
  • 2
  • 11
0

I was running into this issue as well using VS2010, but I just found the solution. You need to provider the Linker with the library file that you are having trouble with.

Project->Properties->Configuration Properties->Linker->Additional Library Directories

Then add the library file that you want into there. Worked for me, hopefully works for you too, and then you don't have to mess with DirectXMath and finding new tutorials for it.

Connor
  • 1