Advertisement

DirectX 9 compilation problems

Started by June 30, 2019 12:00 PM
10 comments, last by Alessio1989 5 years, 6 months ago

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

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

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/
Advertisement

@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

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.

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

'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.

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

 

error run.PNG

Advertisement

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 ?

19 hours ago, wabbz111 said:

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

 

error run.PNG

 

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.

Aether3D Game Engine: https://github.com/bioglaze/aether3d

Blog: http://twiren.kapsi.fi/blog.html

Control

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

 

dependecis.PNG

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.

This topic is closed to new replies.

Advertisement