unresolved external using Direct3DCreate9

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

unresolved external using Direct3DCreate9

Postby alt234 » Fri Mar 02, 2007 6:19 pm

I'm just trying to make a simple prog that makes a window and initializes Direct 3D. When I compile I get an unresolved external error.

Code: Select all
Engine.obj : error LNK2019: unresolved external symbol _Direct3DCreate9@4 referenced in function "public: long __thiscall Engine::InitD3D(void)" (?InitD3D@Engine@@QAEJXZ)


After looking at a ton of examples I'm really not sure what is happening. Here is my header.

Code: Select all
#pragma once

#include <d3dx9.h>

class Engine {
public:
   Engine(HWND, bool, int, int);
   ~Engine();
   HRESULT InitD3D();
   
   // D3D variables
   LPDIRECT3D9         m_pD3D;
   LPDIRECT3DDEVICE9  m_pD3DDevice;

   HWND m_hWnd;

   float m_screenW;
   float m_screenH;
   bool  m_bWindowed;
   bool  m_bRender;
};


The cpp is like so...
Code: Select all
#include "Engine.h"

Engine::Engine(HWND wnd, bool bWindowed, int screen_x, int screen_y) {
   m_pD3D = NULL;
   m_pD3DDevice = NULL;

   m_hWnd = wnd;
   m_bWindowed = bWindowed;
   m_screenW = screen_x;
   m_screenH = screen_y;
   m_bRender = true;

   if(FAILED(InitD3D())) {
      m_bRender = false;
   }
}

Engine::~Engine() {

}

HRESULT Engine::InitD3D() {
   m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);

   if(m_pD3D == NULL) {
      return E_FAIL;
   }

   D3DDISPLAYMODE D3Ddm;
   D3Ddm.Format = D3DFMT_X8R8G8B8;

   D3DPRESENT_PARAMETERS D3Dpp;
   ZeroMemory(&D3Dpp, sizeof(D3Dpp));
   
   D3Dpp.Windowed                 = true;
   D3Dpp.BackBufferCount           = 1;
   D3Dpp.BackBufferFormat           = D3Ddm.Format;
   D3Dpp.MultiSampleType           = D3DMULTISAMPLE_NONE;
   D3Dpp.MultiSampleQuality        = 0;               
   D3Dpp.SwapEffect              = D3DSWAPEFFECT_DISCARD;   
   D3Dpp.hDeviceWindow              = m_hWnd;            
   D3Dpp.Flags                    = 0;                     
   D3Dpp.FullScreen_RefreshRateInHz  = D3DPRESENT_RATE_DEFAULT;
   D3Dpp.PresentationInterval        = D3DPRESENT_INTERVAL_DEFAULT; 
   D3Dpp.BackBufferFormat           = D3Ddm.Format;            
   D3Dpp.EnableAutoDepthStencil     = FALSE;
   
   if(FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
              m_hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &D3Dpp, &m_pD3DDevice))) {
        return E_FAIL;
    }
   return S_OK;
}


Its obviously happening when I try to create the D3D object. Any ideas where my code is going wrong?
User avatar
alt234
 
Posts: 59
Joined: Thu Oct 07, 2004 1:48 pm
Location: Michigan

Postby MXP » Fri Mar 02, 2007 9:07 pm

Did you include the proper libraries? I think one of them is dxguid.lib or something.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby alt234 » Sat Mar 03, 2007 4:50 am

As far as I can tell, yes. I'm linked into the entire lib folder for the SDK as well as with the include files. I can compile other people's DX apps fine as well. I'm using The DX9.0c SDK.
User avatar
alt234
 
Posts: 59
Joined: Thu Oct 07, 2004 1:48 pm
Location: Michigan

Postby MXP » Sat Mar 03, 2007 6:40 am

You cant just have the library folder in your compiler's path, you need to explicitly link the libraries that you are using.

I dont have the DX SDK on my machine so I cant recall exactly what the headers are or the names of the libraries but in the other projects do they include a header similar to initguid.h? You can include that header as an alternative to linking the dxguid.lib (at least, that's how it was in DX 7).
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 3 guests