Problem with Frank Luna's book

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 2375 Views - Last Post: 22 March 2012 - 12:39 PM Rate Topic: -----

#1 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Problem with Frank Luna's book

Posted 22 August 2011 - 05:23 AM

Hi,

Over the last 2 weeks, I have been slowly absorbing DirectX knowledge from Frank Luna's "Introduction to 3D game programming with DirectX 9.0c. A shader approach."

The problem I'm having is that when compiling the code for chapter 4, an error message saying C1083: Cannot open include file: 'dxerr9.h': No such file or directory.

So I linked the libraries and the includes into visual studio as I have done before, and this always worked.
But it didn't solve the problem at hand.

I looked online and some posts stated that the include is out of date.
So I looked into the DirectX SDK folders and noticed that there is a header\lib file for DxErr.
I changed the include statement to #include <DxErr>, which did nothing.
The I tried changing it to #include <dxerr>, and this too did nothing.

So my question is, what can I do to fix this problem?
To those that have read this book, did you have the same problem? Are there any future issues that I will bump into that you can warn me about?

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with Frank Luna's book

#2 SixOfEleven  Icon User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 05:38 AM

The best way to fix this would be to uninstall your current version of the DirectX SDK and then install an older version of the DirectX SDK. Find out when the book was published and search for a release of the SDK that is closest to that date.
Was This Post Helpful? 1
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 07:02 AM

The header has been renamed to DxErr.h without the 9 and the functions don't need the 9 either so you will probably need to rename those. Don't roll back your install just yet :)
Was This Post Helpful? 1
  • +
  • -

#4 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 08:39 AM

View Poststayscrisp, on 22 August 2011 - 07:02 AM, said:

The header has been renamed to DxErr.h without the 9 and the functions don't need the 9 either so you will probably need to rename those. Don't roll back your install just yet :)

I changed it to that before and got the same error message :(
error LNK1104: cannot open file 'DxErr9.lib'

It also created a new warning saying:
Warning 1 warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
Was This Post Helpful? 0
  • +
  • -

#5 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 08:45 AM

Ah, you also need to rename the lib file you link to DxErr.lib instead of DxErr9.lib.

You can disable that warning with a pragma like this:

#pragma warning(disable: 4996)



It is a microsoft specific warning and you can just ignore it if you like or replace with the suggested function. It depends what you're going to be doing or if you plan on distributing your code.
Was This Post Helpful? 1
  • +
  • -

#6 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 09:21 AM

The red swiggly line under the include dissapears when writing #include <DxErr> which means it does exist.

But I still get the same error :S

This is the header file that the error points to.

//=============================================================================
// d3dUtil.h by Frank Luna (C) 2005 All Rights Reserved.
//
// Contains various utility code for DirectX applications, such as, clean up
// and debugging code.
//=============================================================================

#ifndef D3DUTIL_H
#define D3DUTIL_H

// Enable extra D3D debugging in debug builds if using the debug DirectX runtime.  
// This makes D3D objects work well in the debugger watch window, but slows down 
// performance slightly.
#if defined(DEBUG) | defined(_DEBUG)
#ifndef D3D_DEBUG_INFO
#define D3D_DEBUG_INFO
#endif
#endif

#include <d3d9.h>
#include <d3dx9.h>
#include <DxErr.h>
#include <string>
#include <sstream>

#pragma comment(lib, "DxErr.lib")    // I added this line as this is how I usually libraries.

//===============================================================
// Globals for convenient access.
class D3DApp;
extern D3DApp* gd3dApp;
extern IDirect3DDevice9* gd3dDevice;

//===============================================================
// Clean up

#define ReleaseCOM(x) { if(x){ x->Release();x = 0; } }

//===============================================================
// Debug

#if defined(DEBUG) | defined(_DEBUG)
	#ifndef HR
	#define HR(x)                                      \
	{                                                  \
		HRESULT hr = x;                                \
		if(FAILED(hr))                                 \
		{                                              \
			DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \
		}                                              \
	}
	#endif

#else
	#ifndef HR
	#define HR(x) x;
	#endif
#endif 

#endif // D3DUTIL_H



I've added a pragma statement to include the library, but this has no effect.

Any ideas?

This post has been edited by DivideByZero: 22 August 2011 - 09:24 AM

Was This Post Helpful? 0
  • +
  • -

#7 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 10:04 AM

I say just hack it, the only thing dependant on that header that I can see is the #define debug stuff

Remove this line or use a different way of sending error messages.
DXTrace(__FILE__, __LINE__, hr, #x, TRUE);



Then remove the header and be done with it. It's not worth your time to get this to work when there are many other ways to get debug feedback :) Get stuck into the good stuff!
Was This Post Helpful? 1
  • +
  • -

#8 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 11:21 AM

This is getting beyond frustrating.

I've removed the HR macro in the header (as there are some other headers in the d3dutil.h that the other classes relied on, so I couldn't just delete it as I got 200+ errors when deleting it).

I then went through all the code to remove where the macro was being used.

I then deleted the include <DxErr> and built the project as it should work fine.

But for some baffling reason, the error message still says that it can't find DxErr!

Nowhere in the code includes it, so why does it expect it?

I'm going to take a break as this is really annoying me.

Thanks again for helping me get started with DirectX so far.

This post has been edited by DivideByZero: 22 August 2011 - 11:22 AM

Was This Post Helpful? -1
  • +
  • -

#9 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 11:27 AM

Clean the project and recompile, and make sure you have got rid of the header from your property pages if you added it.
Was This Post Helpful? 0
  • +
  • -

#10 bonyjoe  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 178
  • View blog
  • Posts: 548
  • Joined: 08-September 10

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 11:37 AM

It's because you aren't removing it in the project settings. If you're using 2008 it's in tools>options>C++ directories. In 2010 there is apparently a file which does the same thing. But in one of these locations there should be something called additional dependencies which will be referencing all of the d3d libraries in used in the project, including d3derr9
Was This Post Helpful? 1
  • +
  • -

#11 SixOfEleven  Icon User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 01:25 PM

I bet an SDK roll back is sounding easier right about now. ;) j/k

I do hope that you can get this to work out. When you find the solution please let us know what it is. I've been considering going through that book and it would be nice to head that problem off at the pass.
Was This Post Helpful? 1
  • +
  • -

#12 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Problem with Frank Luna's book

Posted 22 August 2011 - 03:56 PM

Been busy today with family. The reason why this is happening is because you haven't set up your paths correctly to find DxErr.h and its libs. To fix you will need to install an older version of the SDK according to this thread, or alternatively if you wish to keep the current you will need to remove the dependencies in the source, as well as removing references from the ensuring you have removed the lib references.

This is a common problem with porting code either between platforms of moving a code base from an older to newer version. :)

This post has been edited by ButchDean: 22 August 2011 - 03:58 PM

Was This Post Helpful? 1
  • +
  • -

#13 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Problem with Frank Luna's book

Posted 23 August 2011 - 02:16 AM

Thanks for the help :)

The thread you linked recommends downloading the December 2004 SDK, so I did a quick google and managed to find that SDK.

I'll give it a download when I get back from work and hopefully I can actually begin with DirectX after 2 weeks :)

Edit: I have a 64bit windows 7 laptop that I do my work in.
My main IDE is Visual Studio 2010 professional edition.

My error senses are tingling and I'm predicting that this will be a problem considering windows 7 and visual studio 2008-2010 weren't released when this SDK came out.
Do you guys know if this will work on my setup?
I installed Visual Studio 2008 last night, just in case, but I'm curious to know if this will be a problem.

This post has been edited by DivideByZero: 23 August 2011 - 02:25 AM

Was This Post Helpful? 0
  • +
  • -

#14 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Problem with Frank Luna's book

Posted 23 August 2011 - 02:35 AM

It shouldn't be a problem if you are coding 32-bit. DirectX is very stable. If you do have problems the second option of manually removing dependencies will be an interesting one for you. :)
Was This Post Helpful? 0
  • +
  • -

#15 DivideByZero  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 240
  • View blog
  • Posts: 551
  • Joined: 02-December 10

Re: Problem with Frank Luna's book

Posted 24 August 2011 - 12:56 PM

An update to this problem.

I uninstalled the sdk and reinstalled the december 2004 sdk.
I then added the lib and include dependencies into visual studio 2008.
Then I built the project and an error saying "Error spawning cl.exe".

Any ideas?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2