Problem with DirectX and Visual Studio 2k5

Hey,

I've noticed something very wierd. I am using Visual Studio 2k5 for sometime but I've never tried to complile my previous Direct3D relelated projects on this release of Visual Studio, maybe because it never occured because the machine that I was developing them had 2k3. Now for the Problem if you create a Win32 default application with MFC support (or not) that you try to write the following stuff you get linker errors and sometimes complier errors. I've never had them before and I don't know why they are occur. I checked for the Project Properties, altered some stuff (such the use of precompiled headers etc with no luck :S). The DirectX samples compile fine but I don't know the cause of the problems with my code. Any ideas?

The code is...

// in our includes

#include "stdafx.h"

#include "dxstdafx.h"

#include "Help_funcs.cpp"

// more includes blah bla

// the rest of the auto-generated VS studio program follows

// and say you want to declare the following function in a separate file i.e. Helper_funcs.cpp

// This is nothing much just a pretty much straight forward way to check your device function

bool CALLBACK IsDevAcceptable( D3DCAPS9* DeviceCaps, // The Device we input for Check
D3DFORMAT BackBufferFMT, // The Format of the back buffer
D3DFORMAT AdapterFMT, // The Format of the Provided Adapter
bool bWindowed, // Is our Window Full Screen or not?
void* UserContext ) // The UserContext
{
// Create our Direct3D Pointer Object and let's assign it to IDirect3D9 interface
IDirect3D9* p_D3D = DXUTGetD3DObject();

// Now first we need pixel proccessing support, let's find out if we have it!

if ( FAILED( p_D3D->CheckDeviceFormat( DeviceCaps->AdapterOrdinal,
DeviceCaps->DeviceType,
AdapterFMT,
D3DUSAGE_RENDERTARGET || D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,
D3DRTYPE_SURFACE,
BackBufferFMT ) ) )

{
return false;
}

// Now we also need to skip those back buffer formats that don't support apha pixel blending

if ( FAILED( p_D3D->CheckDeviceFormat( DeviceCaps->AdapterOrdinal,
DeviceCaps->DeviceType,
AdapterFMT,
D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,
D3DRTYPE_TEXTURE,
BackBufferFMT ) ) )
{
return false;
}

// We Also need floating point render target support from our inputed device so we will check
// if our device is capable of doing so.If so we need to determine how many bits we support
// we can use both 128 bit and 64 bit. In either case we will store the best we have!

if ( FAILED( p_D3D->CheckDeviceFormat( DeviceCaps->AdapterOrdinal,
DeviceCaps->DeviceType,
AdapterFMT,
D3DUSAGE_RENDERTARGET,
D3DRTYPE_TEXTURE,
D3DFMT_A32B32G32R32F ) ) )
{
if ( FAILED( p_D3D->CheckDeviceFormat( DeviceCaps->AdapterOrdinal,
DeviceCaps->DeviceType,
AdapterFMT,
D3DUSAGE_RENDERTARGET,
D3DRTYPE_TEXTURE,
D3DFMT_A16B16G16R16F ) ) )
{
// We don't support neither 64 bit nor 128 bit floating so we can't run this
// sorry pal :-(
return false;
}
}

// We will also need a ShaderModel version 3.0 Support in order to execute this sample
// so we will find if we have that too.

if ( DeviceCaps->PixelShaderVersion < D3DPS_VERSION(3,0) )

{
return false;


}


return true;

}

If you try to compile that you get linker errors, why is that? I do not know :S. So I ask if you know ;)

[3681 byte] By [akaAndr3wGrammenos] at [2007-12-25]
# 1
What errors do you exactly get from the compiler and the linker... Also, make sure your SDK's include and lib paths are at the top of the include and lib directories list of VS2005 (from Tools->Options->Projects->VC++ Directories)...
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 2

Hey,

First of all thanks for answering, I am pretty familiar with the Visual Studio and as well with the Direct3D SDK, as I have done commercial work on such thins so I know how to do these things and I've done them. The the errors are:

1> Build started: Project: Dynamic_Light_HDR, Configuration: Debug Win32

1>Compiling...

1>Dynamic_Light_HDR.cpp

1>Compiling resources...

1>Compiling manifest to resources...

1>Linking...

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CModelViewerCamera::CModelViewerCamera(void)" (?0CModelViewerCamera@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'g_MdlCamera''(void)" (?__Eg_MdlCamera@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CDXUTDialog::CDXUTDialog(void)" (?0CDXUTDialog@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'g_mHUD''(void)" (?__Eg_mHUD@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CD3DSettingsDlg::CD3DSettingsDlg(void)" (?0CD3DSettingsDlg@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'g_SettingsDlg''(void)" (?__Eg_SettingsDlg@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CDXUTDialogResourceManager::CDXUTDialogResourceManager(void)" (?0CDXUTDialogResourceManager@@QAE@XZ) referenced in function "void __cdecl `dynamic initializer for 'g_DialogResourceManager''(void)" (?__Eg_DialogResourceManager@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CDXUTDialog::~CDXUTDialog(void)" (?1CDXUTDialog@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'g_mHUD''(void)" (?__Fg_mHUD@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CD3DSettingsDlg::~CD3DSettingsDlg(void)" (?1CD3DSettingsDlg@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'g_SettingsDlg''(void)" (?__Fg_SettingsDlg@@YAXXZ)

1>Dynamic_Light_HDR.obj : error LNK2019: unresolved external symbol "public: __thiscall CDXUTDialogResourceManager::~CDXUTDialogResourceManager(void)" (?1CDXUTDialogResourceManager@@QAE@XZ) referenced in function "void __cdecl `dynamic atexit destructor for 'g_DialogResourceManager''(void)" (?__Fg_DialogResourceManager@@YAXXZ)

1>Helper_functions.obj : error LNK2019: unresolved external symbol "struct IDirect3D9 * __cdecl DXUTGetD3DObject(void)" (?DXUTGetD3DObject@@YAPAUIDirect3D9@@XZ) referenced in function "bool __stdcall IsDevAcceptable(struct _D3DCAPS9 *,enum _D3DFORMAT,enum _D3DFORMAT,bool,void *)" (?IsDevAcceptable@@YG_NPAU_D3DCAPS9@@W4_D3DFORMAT@@1_NPAX@Z)

1>E:\Documents and Settings\a.ka. Andr3w\My Documents\Visual Studio 2005\Projects\file back\HDR_Tutorial\Debug\Dynamic_Light_HDR.exe : fatal error LNK1120: 8 unresolved externals

1>Build log was saved at "file://e:\Documents and Settings\a.ka. Andr3w\My Documents\Visual Studio 2005\Projects\file back\Dynamic_Light_HDR\Debug\BuildLog.htm"

1>Dynamic_Light_HDR - 9 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

This is the build log and these are the errors if you request so I can include portions of the code

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 3
All of the errors above are regarding DXUT and D3D sample framework classes. Make sure you're including the proper version of the DXUT/D3D sample framework source in your project.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 4

I've noticed that, but I've set on the VS Directories to include them automatically from (InstallFrameworkDIR)/Samples/C++/Common. the version there is from August SDK. It should pose also no problem because the Sample's from the framework run smoothly. Any ideas?

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 5
But adding the directories to your VC++ directories in VS doesn't include the files for compilation in your project. You should add them as part of your workspace so they get compiled and linked with the rest of the modules.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 6

I've included "dxstdafx.h", isn't that enough? (Since it the VS knows where it is and compiles it).

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 7
No. That's the header. You need to include (not #inlcude :) the CPP files for DXUT and the sample D3D framework so they get compiled with the rest of the source code of your project.
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 8

Well, as I said before the Common DIR contains both *.h & *.cpp DXUT files and they do get compiled during the Build process otherwise I would get compiler errors, instead I get link errors. Why?

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 9
You get compile errors if you don't #include the headers, and you get linker errors if you don't include your .cpp files that contain the definitions for the functions in the headers. Simply put, you won't see these linker errors if the linker found the function definitions in the .obj files sent to it...
Just for the sake of assurance, right-click your project in the solution explorer, and choose Add Files..., and select all DXUT and D3D app framework .cpp files under your app directory, then build...
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 10

I've tried that also, I mean I've taken all the Files from the Common Section (it's for the DXUT) and put it in my app DIR then created a filter and added all the files (header and source) to it. It compiles but still I am getting Linker errors. Any ideas?

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 11
Is it possible for you to send a link to a zip file containing the project file along with the accompanying source code?
WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 12

Hey,

Yes definatly, the thing is that the problem happens wher I define the function or not try to compile this file I am senting you. Another thing that is awkwardly strange is that I am getting Windows Error reporting (for VS exe) when I close Vsiaul Studio 2k5 and I have worked with direct3d, dunno why tho...

here is the file http://dl4.megauploads.org/download.php?id=88ACB380.

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 13

Made the following changes:

#include "common/dxstdafx.h" (instead of #include "dxstdafx.h")
Link to: d3d9, d3dx9, winmm, dsound, dxguid, dxerr, comctl32

And it compiles fine... The errors shown were somewhat different than what you posted first. But in general, it was really straightforward to find the missing files/libs.

WessamBahnassi at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...
# 14

Hey,

Thanks for the reply helped a lot, seems I've forgot to set up the linker dependencies....

Kindly,

~a.ka. Andr3w

akaAndr3wGrammenos at 2007-9-3 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: DirectX 101...