fighter92

Hi, I'm trying to build a DirectX program. I get linking error:

main.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function _WinMain@16

I get the error using this line of code:

g_D3D = Direct3DCreate9( D3D_SDK_VERSION);

Where should I link



Re: Visual C++ General Where should I link?

einaros

d3d9.lib, I believe. When you're about to ask such questions, see the documentation which ships with DirectX. Navigate to the referenced function, e.g. Direct3DCreate9, and look for a library reference.




Re: Visual C++ General Where should I link?

fighter92

I have linked there, but it doesn't help




Re: Visual C++ General Where should I link?

einaros

fighter92 wrote:
I have linked there, but it doesn't help

The docs specify that library, so I'm guessing you aren't linking the right file after all. Where have you added the dependency

As an alternative approach, you could try adding the following, e.g. to the header in which you call the Direct3DCreate9 function:

#pragma comment(lib, "d3d9.lib")






Re: Visual C++ General Where should I link?

fighter92

I have the line. Althow I found my mistake on my own. I linked d3d9.lib from x64 folder instead of x86. It works, if I link it from x86 folder.