2D DirectX 9 compilation problems

Recommended Posts

I'm trying to compile the July07 source  code from GDMag   link here

I'm using Visual Studio 2008 and Microsoft DirectX SDK (June 2010) i managed to compile and run different direct x projects

but this one is giving the following errors

>scatter.obj : error LNK2001: unresolved external symbol _c_dfDIJoystick2
1>scatter.obj : error LNK2019: unresolved external symbol _DirectInput8Create@20 referenced in function "long __cdecl InitDirectInput(struct HWND__ *)" (?InitDirectInput@@YAJPAUHWND__@@@Z)
1>scatter.obj : error LNK2001: unresolved external symbol _IID_IDirectInput8A

Any help on this will be greatly appreciated.

Regards

Share on other sites

You need to link the DirectInput static library (dinput8.lib).

Share on other sites
Posted (edited)

@Alessio1989 Thanks for reply, I have done as you recommended now it builds with warnings but no errors.

warning C4305: 'return' : truncation from 'HRESULT' to 'bool'
1>Mesh.cpp
1>Generating Code...
warning C4715: 'Game::InitGame' : not all control paths return a value

However on running it closes unexpectedly and throws exception with the error below

Unhandled exception at 0x01184257 in dxgame.exe: 0xC0000005: Access violation reading location 0x00000000.

Regards

Edited by wabbz111
not all information was included

Share on other sites
Quote

@Alessio1989 Thanks for reply, I have done as you recommended now it builds with warnings but no errors.

The warning is about casting an HRESULT (which should be mapped to long IIRC) to bool which cause information loss: not all HRESULT values different from S_OK (0x00000000) are meant to be errors, in fact positive values (>= 0) are considered a successful operation while negatives values are not, so casting it to bool wrong.

Quote

However on running it closes unexpectedly and throws exception with the error below

This is 99.999% related to your code, probably you are trying to deference a null pointer.

Share on other sites
'Game::InitGame

Does not return object in some of its paths, this might couse your memory leak, or not, but you need to accunt for this warning in particular.

Share on other sites

Some progress and apologies in advance to @Alessio1989 and @JohnnyCode the errors i posted were not for the code in the original post. The code in the original post has run but i still get a runtime error(please see attached image) that is beyond my understanding. Any idea on what the error means and how it can be resolved? Regards

Share on other sites
Posted (edited)

Pretty much what it says: a NULL pointer is passed to fprintf().

Didn't stepping through the code with a debugger reveal the offending part ?

Edited by Green_Baron

Share on other sites
19 hours ago, wabbz111 said:

Any idea on what the error means and how it can be resolved

If you press "Retry", you should see exactly where it crashes. Then you can inspect the callstack and local variables to see their values. In this case, a variable named "str" is null.

Share on other sites

An update of this project as i had to reinstall Visual C++ 2008 express.

The following are the errors

error LNK2001: unresolved external symbol _c_dfDIJoystick2
error LNK2001: unresolved external symbol _DirectInput8Create@20
error LNK2001: unresolved external symbol _D3DXCreateFontA@48
error LNK2001: unresolved external symbol _IID_IDirectInput8A

A google search shows that these errors are caused by a missing file namely dinput8.h.  However the SDK only comes with dinput.h and not dinput8.h.

I have tried searching for the dinput8.h file on google but iam just finding a wrapper file located   here which i have inserted in my include folder. However this file has too many dependencies(header files also missing in the SDK)  thus causing more errors than i can comprehend

I have linked the .lib files in my project correctly as per the screenshot and earlier reccomendations on this thread so i have no clue how to resolve this.

Regards

Share on other sites

You are compiling against DirectX 8. I hardly doubt you can find deployable kit for dx8 anymore. You need to migrate the code to at least dx9 or newer.

Create an account

Register a new account

• 18
• 18
• 11
• 21
• 16