locked
Linker Problems RRS feed

  • Question

  • Hello People
    This Editor just ate up my entire post *sigh* so I'm having to type it all again. So I'll be a little brief. I'm getting linker errors and I know this is probably the first error any person who starts learning DirectX will get and I could easily find an answer if I looked. Well I have looked and I have found a temp soloution. But I want a permanent one.

    I am currently using Windows XP SP2, Visual C++ 2005 Express Edition, Microsoft Platform SDK for Windows Server 2003 R2, DirectX SDK Dec version. On installing the above in the respective order given I went to C++ ->Tools -> Options and Manually Included C:\DXSDK\Lib & C:\DXSDK\Include in their respective locations.

    Now I'm trying to compile a simple DirectX window which displays a blank screen. And I'm getting the following Error

    1>------ Build started: Project: DirectX, Configuration: Debug Win32 ------
    1>Compiling...
    1>Main.cpp
    1>Linking...
    1>d3dUtility.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 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)
    1>d3dUtility.obj : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function "int __cdecl d3d::EnterMsgLoop(bool (__cdecl*)(float))" (?EnterMsgLoop@d3d@@YAHP6A_NM@Z@Z)
    1>C:\Documents and Settings\vh\My Documents\Visual Studio 2005\Projects\DirectX\Debug\DirectX.exe : fatal error LNK1120: 2 unresolved externals
    1>Build log was sa ...

    Realizing it was a Link problem I went to My Project Properties and in the Linker Input section in Additional Dependencies I added d3d9lib,d3dx9.lib. To which I then got an error that the complier could not find these files. So I removed what I just added.

    Fianlly I thought of Manually including them by the following lines
    #pragma comment (lib, "d3d9.lib")
    #pragma comment (lib, "d3dx9.lib")
    #pragma comment (lib, "winmm.lib") -  I read about this in a book

    And Then it works but now I don't want to add these lines to every project that I make (I could It's not much of an effort) but I would rather know whats wrong with my Compiler and How can I fix it.

    And another weird thing I noticed was that if I do not include those above lines (pragma ones) and If a I look in Visual C++->Tools->Options and in the Include path where I have included the DirectX include dir.
    The DirectX include dir is below the Windows SDK include dir. If I subsequently change the order and recompile. I get the following errors

    1>c:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
    1>c:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'
    1>c:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>c:\program files\microsoft platform sdk for windows server 2003 r2\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    which to me makes no sense at all. So I have reverted back to the original state where the Windows  Include Dir is above the DirectX include Dir.

    Well thats the end of my problem. So if anyone could help I would be great full !!
    Thursday, April 26, 2007 6:02 PM

Answers

  • Just for the Info I found the problem

    Realizing it was a Link problem I went to My Project Properties and in the Linker Input section in Additional Dependencies I added d3d9lib,d3dx9.lib. To which I then got an error that the complier could not find these files. So I removed what I just added.


    I added d3d9.lib,d3dx9.lib
    the commas were the problem they were suposed to be serperated by blank spaces !!
    Thursday, May 3, 2007 11:12 AM