Linking Problems

This is a discussion on Linking Problems within the Game Programming forums, part of the General Programming Boards category; Im trying to draw font in D3D using the font class included with the Direct X 9 SDK but im ...

  1. #1
    Banned
    Join Date
    Oct 2004
    Posts
    250

    Linking Problems

    Im trying to draw font in D3D using the font class included with the Direct X 9 SDK but im getting a linker error is thier a lib file i need to get ?

    Code:
    #include <D3DFont.h>
    Code:
    CD3DFont* m_pFont;
    m_pFont                  = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
    Code:
    m_pFont->DrawText( 2,  0, D3DCOLOR_ARGB(255,255,255,0), "This is a test ");
    Code:
    ------ Build started: Project: DX9, Configuration: Debug Win32 ------
    
    Linking...
    main.obj : error LNK2019: unresolved external symbol "public: long __thiscall CD3DFont::DrawTextA(float,float,unsigned long,char const *,unsigned long)" (?DrawTextA@CD3DFont@@QAEJMMKPBDK@Z) referenced in function "int __cdecl DrawD3DScene(void)" (?DrawD3DScene@@YAHXZ)
    main.obj : error LNK2019: unresolved external symbol "public: __thiscall CD3DFont::CD3DFont(char const *,unsigned long,unsigned long)" (??0CD3DFont@@QAE@PBDKK@Z) referenced in function "int __cdecl DrawD3DScene(void)" (?DrawD3DScene@@YAHXZ)
    Debug/DX9.exe : fatal error LNK1120: 2 unresolved externals
    
    Build log was saved at "file://c:\C++\Dx9\Debug\BuildLog.htm"
    DX9 - 3 error(s), 0 warning(s)
    
    
    ---------------------- Done ----------------------
    
        Build: 0 succeeded, 1 failed, 0 skipped
    any help in this would be appriceated

  2. #2
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656

  3. #3
    Banned
    Join Date
    Oct 2004
    Posts
    250
    There are no pronlems compiling anything else in Direct X just this font class ...
    looks like im going to have to find another way to draw font

  4. #4
    Banned
    Join Date
    Oct 2004
    Posts
    250
    I cant evean get ID3DXFont to work maybe there's something wrong with my compiler....

    Code:
    int DrawD3DScene()                                        
    {
        HRESULT hr = D3D_OK;
        ID3DXFont *g_font=NULL;
    
        HRESULT WINAPI D3DXCreateFont(
        pD3DDevice,
        22,
        0,
        FW_NORMAL,
        1,
        false,
        DEFAULT_CHARSET,
        OUT_DEFAULT_PRECIS,
        ANTIALIASED_QUALITY,
        DEFAULT_PITCH|FF_DONTCARE,
        "Arial",
        &g_font
    );
        pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                                    D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,0.0f), 1.0f, 0 );
    
        D3DXMATRIXA16 matWorld;    
    
        pD3DDevice->BeginScene();
                    
    
        pD3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX);            
        pD3DDevice->SetStreamSource(0,pVertexBuffer, 0, sizeof(tVertex));
    
        D3DXMatrixTranslation(&matWorld,-1.5,0.0f,6.0f);    
        pD3DDevice->SetTransform(D3DTS_WORLD,&matWorld );    
        pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);    
        
    
        D3DXMatrixTranslation(&matWorld,1.5,0.0f,6.0f);        
        pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );    
        pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,3,2);    
        g_font->Begin();
        g_font->DrawText("this is a test",-1,NULL,DT_NOCLIP|DT_LEFT,0xFFFFFFFF);
        g_font->End();
    
    
        pD3DDevice->EndScene();
        
        pD3DDevice->Present( NULL, NULL, NULL, NULL );        
    
        return TRUE;                                        
    }
    Code:
    ------ Build started: Project: DX9, Configuration: Debug Win32 ------
    
    Compiling...
    main.cpp
    c:\C++\DX9\main.cpp(142) : warning C4229: anachronism used : modifiers on data are ignored
    c:\C++\DX9\main.cpp(142) : error C2078: too many initializers
    c:\C++\DX9\main.cpp(142) : error C2440: 'initializing' : cannot convert from 'ID3DXFont **__w64  ' to 'HRESULT'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    c:\C++\DX9\main.cpp(513) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
    
    Build log was saved at "file://c:\C++\Dx9\Debug\BuildLog.htm"
    DX9 - 2 error(s), 2 warning(s)
    
    
    ---------------------- Done ----------------------
    
        Build: 0 succeeded, 1 failed, 0 skipped
    Last edited by cgod; 01-29-2005 at 09:35 PM.

  5. #5
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Try this I suppose:
    Code:
    int DrawD3DScene()                                        
    {
        HRESULT hr = (HRESULT)D3D_OK;
        ID3DXFont *g_font=NULL;
    
        HRESULT WINAPI D3DXCreateFont(
        pD3DDevice,
        22,
        0,
        FW_NORMAL,
        1,
        false,
        DEFAULT_CHARSET,
        OUT_DEFAULT_PRECIS,
        ANTIALIASED_QUALITY,
        DEFAULT_PITCH|FF_DONTCARE,
        "Arial",
        &g_font
    );
        pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 
                                    D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,0.0f), 1.0f, 0 );
    
        D3DXMATRIXA16 matWorld;    
    
        pD3DDevice->BeginScene();
                   
    
        pD3DDevice->SetFVF(D3DFVF_CUSTOMVERTEX);            
        pD3DDevice->SetStreamSource(0,pVertexBuffer, 0, sizeof(tVertex));
    
        D3DXMatrixTranslation(&matWorld,-1.5,0.0f,6.0f);    
        pD3DDevice->SetTransform(D3DTS_WORLD,&matWorld );    
        pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);    
        
    
        D3DXMatrixTranslation(&matWorld,1.5,0.0f,6.0f);        
        pD3DDevice->SetTransform( D3DTS_WORLD, &matWorld );    
        pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,3,2);    
        g_font->Begin();
        g_font->DrawText("this is a test",-1,NULL,DT_NOCLIP|DT_LEFT,0xFFFFFFFF);
        g_font->End();
    
    
        pD3DDevice->EndScene();
        
        pD3DDevice->Present( NULL, NULL, NULL, NULL );        
    
        return TRUE;                                        
    }

  6. #6
    Banned
    Join Date
    Oct 2004
    Posts
    250
    more error's
    Code:
    ------ Build started: Project: DX9, Configuration: Debug Win32 ------
    
    Compiling...
    main.cpp
    c:\C++\DX9\main.cpp(142) : warning C4229: anachronism used : modifiers on data are ignored
    c:\C++\DX9\main.cpp(142) : error C2078: too many initializers
    c:\C++\DX9\main.cpp(142) : error C2440: 'initializing' : cannot convert from 'ID3DXFont **__w64  ' to 'HRESULT'
            This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    c:\C++\DX9\main.cpp(512) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
    
    Build log was saved at "file://c:\C++\Dx9\Debug\BuildLog.htm"
    DX9 - 2 error(s), 2 warning(s)
    
    
    ---------------------- Done ----------------------
    
        Build: 0 succeeded, 1 failed, 0 skipped
    this is realy starting to want to make me go back to OpenGL :/

  7. #7
    UT2004 Addict Kleid-0's Avatar
    Join Date
    Dec 2004
    Posts
    656
    Quote Originally Posted by cgod
    this is realy starting to want to make me go back to OpenGL :/
    Well, try out these Google searching, I'm really lazy today...and nobody else is helping on this thread, grrr:
    • ID3DXFont DX9
    • DX9 Font troubles
    • "too many initializers" DX9
    • ID3DXFont Direct X 9
    • Direct X 9 Font troubles
    • "too many initializers" Direct X 9

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ OpenGL linking problems
    By KoshiB in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2006, 05:25 PM
  2. Linking problems, class problems
    By Kheila in forum C++ Programming
    Replies: 12
    Last Post: 11-22-2005, 01:47 AM
  3. Linking problems trying to compile QT application
    By Maragato in forum C++ Programming
    Replies: 1
    Last Post: 08-19-2005, 10:08 PM
  4. Grrr.... SDL Linking Problem
    By 7EVEN in forum Game Programming
    Replies: 5
    Last Post: 08-12-2005, 09:44 PM
  5. More linker problems
    By Ganoosh in forum C++ Programming
    Replies: 4
    Last Post: 07-12-2005, 11:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21