Jump to content
  • Advertisement
Sign in to follow this  
MrSqweaky

C++ Linker error?

This topic is 2501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[sub]Hello![/sub]

[sub]I have a question for u guys, i have tried to compile my code for the two-kings.de tutorial, everthing worked fine until the second lesson. I see to have a strange linker error. tried to look up wich lib was causing this error, no succes so far. So i think u guys can help me out with this error, it bougles my mind :l[/sub]

[sub]The error i get is this:[/sub]

[sub]1>capplication.obj : error LNK2019: unresolved external symbol "public: void __thiscall CApplication::CheckDeviceCaps(void)" (?CheckDeviceCaps@CApplication@@QAEXXZ) referenced in function "public: void __thiscall CApplication::InitD3D(void)" (?InitD3D@CApplication@@QAEXXZ)
1>C:\Users\Alx\Documents\Visual Studio 2008\Projects\twoking\Debug\twoking.exe : fatal error LNK1120: 1 unresolved externals
[/sub]

Here is my CApplication header
[size=2]]#ifndef capplication_h
#define capplication_h
[size=2]#include"main.h"
[size=2]class CApplication
{
public:
CApplication(void);
~CApplication(void);

[size=2]//win32 stuff
void InitWindow(void);
void SaveSettings(void);
void LoadSettings(void);
void KillWindow(void);
[size=2]//d3d stuff
void InitD3D(void);
void InitScene(void);
void CheckDeviceCaps(void);
bool CheckDevice(void);
void KillD3D(void);

[size=2]//win32 prototypes
inline bool GetWindowStatus(void)
{
return m_bRunningWindow;
}
inline HWND GetWindowHandle(void)
{
return m_hWindow;
}
inline void SetWindowStatus(bool bRunningWindow)
{
m_bRunningWindow = bRunningWindow;
}
[size=2]//d3d
inline bool GetD3DStatus(void)
{
return m_bRunningD3D;
}
inline LPDIRECT3DDEVICE9 GetDevice(void)
{
return m_pDirect3DDevice;
}
inline void SetD3DStatus(bool bRunningD3D)
{
m_bRunningD3D = bRunningD3D;
}


[size=2]//win32
private:
bool m_bRunningWindow,
m_bRunningD3D;
[size=2] HWND m_hWindow,
m_hBtnStart,
m_hBtnCancel,
m_hLblResolution,
m_hCbResolution,
m_hLblBackBuffer,
m_hCbBackBuffer,
m_hLblDepthStencil,
m_hCbDepthStencil,
m_hLblVertexProcessing,
m_hCbVertexProcessing,
m_hLblMultiSampling,
m_hCbMultiSampling,
m_hLblAnisotropy,
m_hCbAnisotropy;
[size=2] LPDIRECT3D9 m_pDirect3DObject;
LPDIRECT3DDEVICE9 m_pDirect3DDevice;
D3DPRESENT_PARAMETERS m_PresentParameters;
D3DCAPS9 m_DeviceCaps;
[size=2] DWORD m_dwWidth,
m_dwHeight,
m_dwVertexProcessing,
m_dwAnisotropy;
D3DFORMAT m_ColorFormat,
m_DepthStencilFormat;
D3DMULTISAMPLE_TYPE m_MultiSampling;
[size=2] D3DXMATRIX m_matProjection;
float m_fAspectRatio,
m_fFieldOfView,
m_fNearPlane,
m_fFarPlane;
};
[size=2]#endif



And here my CApplication cpp file
[size=2]#include "main.h"

[size=2]CApplication::CApplication(void)
{
m_pDirect3DObject = NULL;
m_pDirect3DDevice = NULL;
[size=2] m_dwWidth = 800;
m_dwHeight = 600;
[size=2] m_ColorFormat = D3DFMT_R5G6B5;
m_DepthStencilFormat = D3DFMT_D16;
m_dwVertexProcessing = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
m_MultiSampling = D3DMULTISAMPLE_NONE;
m_dwAnisotropy = 0;
[size=2] m_fFieldOfView = D3DX_PI / 4.0f;
m_fNearPlane = 1.0f;
m_fFarPlane = 1000.0f;
m_fAspectRatio = (float)m_dwWidth / (float)m_dwHeight;
[size=2] m_bRunningWindow = true;
m_bRunningD3D = false;
[size=2] InitWindow();
}
[size=2]CApplication::~CApplication(void)
{
KillD3D();
KillWindow();
}
[size=2]void CApplication::InitWindow(void)
{
WNDCLASSEX screen;
RECT size;
[size=2]InitCommonControls();
GetClientRect(GetDesktopWindow(), &size);
[size=2]screen.cbSize = sizeof(WNDCLASSEX);
screen.style = CS_HREDRAW | CS_VREDRAW;
screen.lpfnWndProc = WindowProcedure;
screen.cbClsExtra = 0;
screen.cbWndExtra = 0;
screen.hInstance = GetModuleHandle(NULL);
screen.hIcon = NULL;
screen.hCursor = NULL;
screen.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
screen.lpszMenuName = NULL;
screen.lpszClassName = "Classname";
screen.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
[size=2]RegisterClassEx(&screen);
[size=2]m_hWindow = CreateWindowEx(WS_EX_CONTROLPARENT,
"Classname",
TITLE,
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE,
((1650 / 2) - WINDOW_X) + (WINDOW_X / 100 * 55) ,
((1050 / 2) - WINDOW_Y) + (WINDOW_Y / 100 * 45) ,
WINDOW_X,
WINDOW_Y,
NULL,
NULL,
GetModuleHandle(NULL),
NULL);
[size=2]m_hLblResolution = CreateWindow("static",
"Hai:3",
WS_CHILD | WS_VISIBLE | SS_LEFT,
20,
20,
200,
18,
m_hWindow,
NULL,
(HINSTANCE)GetWindowLong(m_hWindow, GWL_HINSTANCE),
NULL);
SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"640 x 480");
SendMessage(m_hCbResolution,CB_ADDSTRING,0,(long)"800 x 600");
[size=2]LoadSettings();
}
[size=2]void CApplication::InitD3D(void)
{
if((m_pDirect3DObject = Direct3DCreate9(D3D_SDK_VERSION)) == NULL)
{
MessageBox(m_hWindow, "[0x0]Failed to create Direct3D Object", "Init D3D", MB_OK);
m_bRunningD3D = false;
}
ZeroMemory(&m_PresentParameters, sizeof(m_PresentParameters));
m_PresentParameters.Windowed = false;
m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_PresentParameters.EnableAutoDepthStencil = true;
m_PresentParameters.AutoDepthStencilFormat = m_DepthStencilFormat;
m_PresentParameters.hDeviceWindow = m_hWindow;
m_PresentParameters.BackBufferWidth = m_dwWidth;
m_PresentParameters.BackBufferHeight = m_dwHeight;
m_PresentParameters.BackBufferFormat = m_ColorFormat;
m_PresentParameters.MultiSampleType = m_MultiSampling;
[size=2]if(FAILED(m_pDirect3DObject->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,m_hWindow,m_dwVertexProcessing,&m_PresentParameters,&m_pDirect3DDevice)))
{
MessageBox(m_hWindow, "[0x1]Failed to create Direct3D Device", "Init D3D", MB_OK);
m_bRunningD3D = false;
}
ShowCursor(false);
[size=2]InitScene();
CheckDeviceCaps();
}
void CApplication::InitScene(void)
{
D3DXMatrixPerspectiveFovLH(&m_matProjection, m_fFieldOfView,m_fAspectRatio,m_fNearPlane,m_fFarPlane);
m_pDirect3DDevice->SetTransform(D3DTS_PROJECTION,&m_matProjection);
[size=2]for(unsigned i = 0;i < 8;++i)
{
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MIPFILTER,D3DTEXF_ANISOTROPIC);
m_pDirect3DDevice->SetSamplerState(i,D3DSAMP_MAXANISOTROPY,m_dwAnisotropy);
}
}
[size=2]bool CApplication::CheckDevice(void)
{
switch(m_pDirect3DDevice->TestCooperativeLevel())
{
case D3DERR_DEVICELOST:
{
MessageBox(m_hWindow,"[0x2]Device has been lost","CheckDevice()",MB_OK);
return false;
}
case D3DERR_DEVICENOTRESET:
{
if(FAILED(m_pDirect3DDevice->Reset(&m_PresentParameters)))
{
MessageBox(m_hWindow,"[0x3]Device failed to reset","CheckDevice()",MB_OK);
return false;
}
return true;
}
default: return true;
}
}
[size=2]void CApplication::KillD3D(void)
{
if(m_pDirect3DDevice != NULL)
{
m_pDirect3DDevice->Release();
m_pDirect3DDevice = NULL;
}
if(m_pDirect3DObject != NULL)
{
m_pDirect3DObject->Release();
m_pDirect3DObject = NULL;
}
[size=2]}
[size=2]void CApplication::LoadSettings(void)
{
}
[size=2]void CApplication::SaveSettings(void)
{
}
[size=2]void CApplication::KillWindow(void)
{
UnregisterClass("ClassName",GetModuleHandle(NULL));
}

Share this post


Link to post
Share on other sites
Advertisement

You don't seem to have a function definition for your CheckDeviceCaps() function.


The tutorial said we will be covering that on a later stage of our programming course.

What u saying is just add the function definition
CApplication::CheckDeviceCaps(void)
{
//Do Nothing.
}


Edit: Worked fine, tutorial actually didnt say u need to define that:)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!