Weird D3D linker error

This is a discussion on Weird D3D linker error within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to learn Direct3D using a tutorial I found on the Net ( http://www.experimentsingameprogramming.com/) . I followed the author's ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    2

    Question Weird D3D linker error

    I'm trying to learn Direct3D using a tutorial I found on the Net (http://www.experimentsingameprogramming.com/).

    I followed the author's instructions to the letter and everything worked great UNTIL he added a class that works with fonts:

    Code:
    #include "dxText.h"
    
    dxText::dxText(void)
    {
    	g_font = NULL; //The font object
    }
    
    dxText::~dxText(void)
    {
    	if( g_font != NULL) 
    	{
            g_font->Release();
    		g_font = NULL;
    	}
    }
    
    
    bool dxText::init(DWORD size, LPDIRECT3DDEVICE9 device)
    {
    	// Create a font
    	D3DXCreateFont(device, //D3D Device
    		size, //Font height
    		0, //Font width
    		FW_NORMAL, //Font Weight
    		1, //MipLevels
    		false, //Italic
    		DEFAULT_CHARSET, //CharSet
    		OUT_DEFAULT_PRECIS, //OutputPrecision
    		ANTIALIASED_QUALITY, //Quality
    		DEFAULT_PITCH|FF_DONTCARE,//PitchAndFamily
    		"Arial", //pFacename,
    		&g_font); //ppFont
    
    	return true;
    }
    
    void dxText::drawText(std::string text, int x, int y, int width, int height)
    {
    	RECT font_rect = {0,0,width,height}; //sets the size of our font surface rect
    
    	//set the destination for our text, by moving the font rect.
    	SetRect(&font_rect, //our font rect
    		x, //Left
    		y, //Top
    		width, //width
    		height //height
    		);
    
    	//draw our text
    	g_font->DrawText(NULL, //pSprite
    		text.c_str(), //pString
    		-1, //Count
    		&font_rect, //pRect
    		DT_LEFT|DT_NOCLIP,//Format,
    		0xFFFFFFFF); //Color (white)
    
    }
    Anyway, this and the rest of the code compiles just fine, but the linker says

    Code:
    dxtext.obj : error LNK2019: unresolved external symbol _D3DXCreateFontA@48 referenced in function "public: bool
     __thiscall dxText::init(unsigned long,struct IDirect3DDevice9 *)" (?init@dxText@@QAE_NKPAUIDirect3DDevice9@@@Z)
    Debug/dblock.exe : fatal error LNK1120: 1 unresolved externals
    The DirectX libs are included, as are the necessary headers (the directories are set and I added the additional dependencies). I have been checking and double checking the settings all day long but haven't gotten anywhere.

    Then I downloaded and tried to build the author's own project files, but got the exact same error.

    Nothing that Google turned up has helped either.

    Since I'm all out of ideas, I'd be really greatful if somebody could help.

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    The declaration I find of this function on MSDN is something like;

    Code:
    HRESULT D3DXCreateFont(
      LPDIRECT3DDEVICE8 pDevice,
      HFONT hFont,
      LPD3DXFONT* ppFont
    );

  3. #3
    Registered User
    Join Date
    Feb 2006
    Posts
    2
    Quote Originally Posted by Tonto
    The declaration I find of this function on MSDN is something like;

    Code:
    HRESULT D3DXCreateFont(
      LPDIRECT3DDEVICE8 pDevice,
      HFONT hFont,
      LPD3DXFONT* ppFont
    );
    Yeah, but there's another declaration tha goes

    Code:
    HRESULT D3DXCreateFont(
      LPDIRECT3DDEVICE9 pDevice,
      INT Height,
      UINT Width,
      UINT Weight,
      UINT MipLevels,
      BOOL Italic,
      DWORD CharSet,
      DWORD OutputPrecision,
      DWORD Quality,
      DWORD PitchAndFamily,
      LPCTSTR pFacename,
      LPD3DXFONT * ppFont
    );
    The one you posted is the DX8.1 version, whereas I want the 9.0 one. You'd think that including the 9.0 header and lib would do the trick but I'm obviously missing something...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  2. failure to import external C libraries in C++ project
    By nocturna_gr in forum C++ Programming
    Replies: 3
    Last Post: 12-02-2007, 02:49 PM
  3. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  4. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 06:33 AM
  5. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM

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