Help with book code

Started by
14 comments, last by Steve_Segreto 11 years, 3 months ago

Hi, i'm studying directx with the book "Introduction To 3D Game Programming With DirectX 9" but the sample of the first chapter isn't compiling in Visual Studio C++ Express Edition, the compiler output show this error


1>d3dUtility.obj : error LNK2019: unresolved external symbol "long __stdcall d3d::WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@d3d@@YGJPAUHWND__@@IIJ@Z) referenced in function "bool __cdecl d3d::InitD3D(struct HINSTANCE__ *,int,int,bool,enum _D3DDEVTYPE,struct IDirect3DDevice9 * *)" (?InitD3D@d3d@@YA_NPAUHINSTANCE__@@HH_NW4_D3DDEVTYPE@@PAPAUIDirect3DDevice9@@@Z)

I don't know how to fix this and i think the book code is correct. Can anyone help me?

Advertisement

UP!

Make sure you've set your project up correctly. Double check the settings you've used, specifically for library linking, against the ones given to you by the book.

You're getting this error because the linker (which is invoked after the compiler) is unable to locate the library containing the Direct3D functions you're attempting to call.

I'm thinking i'm doing this correct, i linked to the correct libraries, but this error don't disappear

That's because you didn't define that function. You've declared it somewhere, but not defined it. As such the linker cannot find the definition for the function and is wondering what you're talking about.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Are you talking about the function prototype?

No the function prototype is the declaration, the definition is the actual body of the function.

http://www.cprogramming.com/declare_vs_define.html

But this is one possibilitie or can have another errors?

I don't have the book you mentioned - can you post the code for the definition of d3d::WndProc()?

Washu and Steve are right - when your d3dUtility object file is being linked to all the other functions that it references, there is a missing implementation to that d3d::WndProc function. The error you showed is very clear - but the cause of the error could be a number of different things. Did you get any compilation errors at all? Are there other libraries that you need to compile first? Please reference the instructions from the book very clearly and make sure you have followed them to the letter!

This topic is closed to new replies.

Advertisement