I couldnt decide whether to put this question here (as I'm programming with DirectX) or in the C++ section.

I seem to only get this error occasionally. I understand the MSDN examples, and how they work. But I'm wondering if anyone can give a more human explanation?

See, this only happens to me when I'm trying to use DirectX objects/functions, etc. For example these lines:

D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
    D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
    D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );

Generate an LNK2019 each. They're call from within one of my own functions "SetupMatrices()".

I've actually been building this from a tutorial (its beginners DirectX for C++ Veterans) where the source code compiles and runs perfectly, yet, even pasting the source into my project (or even only pasting SMALL parts of it) yields the Unresolved external errors.

I dont understand the error fully, nor what I can do to resolve it. Any suggestions?

Thanks!

*Also, I have had this project working before i tried setting up matrices and whatnot, so I know the includes and libs are setup properly. I've compared my code to the tutorial source, line for line, and I can't see anything that is noticibly different. There are minor differences, but I can't see them affecting functionality.

Dani AI

Generated

A plain explanation up front: LNK2019 means the linker found a declaration (from a header) but could not find the corresponding definition (in any .obj or .lib). Headers let the compiler compile code; the linker needs the actual compiled code or import library that supplies the symbol. For DirectX this often shows up when the core D3D runtime is linked (so a device can be created) but the D3DX utility library that supplies math helpers and helpers (such as the D3DX math symbols) is missing from the link step.

As hinted, this is almost always a project-linker configuration issue. Given reports a blank device renders, the core D3D library is present but the D3DX module (the one that provides D3DXVECTOR3 and similar helpers) is not being linked into the current build configuration. Project-level entries matter: the SDK include/lib paths can be correct while the Linker -> Input -> Additional Dependencies is missing the D3DX import library (and the correct variant for the active configuration/platform).

A short troubleshooting checklist (minimal, practical):

  • Verify Linker -> Input -> Additional Dependencies contains the D3DX import library appropriate to the SDK and build (ensure correct debug/release and Win32/x64 variant).
  • Confirm Linker -> General -> Additional Library Directories points at the matching SDK lib folder for the active platform.
  • Make sure no project .cpp files with needed definitions were left out of the project, and that Ignore All Default Libraries is not set.
  • If the LNK2019 name looks mangled, inspect it to confirm which module should provide it (D3DX vs d3d9 vs user code).

If those are correct, a clean rebuild and comparing the tutorial project file’s Linker -> Input entries side-by-side will usually reveal the missing library setting.

Recommended Answers

All 2 Replies

The problem is that D3DXVECTOR3 is not being found for whatever
reason. Have you linked ALL of the lib and headers? Maybe something
got corrupted.

>>I've actually been building this from a tutorial (its beginners DirectX for C++ Veterans) where the source code compiles and runs perfectly, yet, even pasting the source into my project (or even only pasting SMALL parts of it) yields the Unresolved external errors.

This tells me that you are not linking your lib and headers properly.
Why, because when you unzip their project, included are the dlls
for directX and thus the .exe works because it finds them in the same
directory. But you say that you pasted the code and it gives you
a linking error, which definitely means that you did not link the files
correctly.

Thanks. I'll look into it. The only problem I see with the solution is that I can get a blank device up and rendering in the same project (you know, the blue-filled window). Are there separate libraries that include the DX maths and the Device classes?

What I've got is (under right click project->properties->VC++ Directories->Include Directories) $(DXSDK_DIR)include

And under Library directories I have $(DXSDK_DIR)lib\x86\

I havent modified anyhting under executable directories, reference directories, source directories, or exclude directories. Do I need to add something? or is there a typo in my includes/library directories?

I appreciate the insight you've given me. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.