Sign in to follow this  

linking error

Recommended Posts

I am getting an unresolved external symbol error. Here is the code of my class: #include "DisplayManager.h" ID3DXMesh* Car = 0; //variables should be declared in .cpp files to prevent them from being declared by including files (winmain.cpp) LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; LPDIRECT3DSURFACE9 backbuffer; DisplayManager::DisplayManager(HWND hwnd) : CProcess( PROC_SCREEN, 0) { } DisplayManager::~DisplayManager(void) { } LPDIRECT3DSURFACE9 LoadSurface(char *filename, D3DCOLOR transcolor) { LPDIRECT3DSURFACE9 image = NULL; D3DXIMAGE_INFO info; HRESULT result; //get width and height from bitmap file result = D3DXGetImageInfoFromFile(filename, &info); if (result != D3D_OK ) return NULL; //create surface result = d3ddev->CreateOffscreenPlainSurface( info.Width, info.Height, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &image, NULL); if (result != D3D_OK) return NULL; //load surface from file into newly created surface result = D3DXLoadSurfaceFromFile( image, NULL, NULL, filename, NULL, D3DX_DEFAULT, transcolor, NULL); //make sure the file was loaded ok if (result != D3D_OK) return NULL; return image; } int DisplayManager::Draw(HWND hwnd) { LPDIRECT3DSURFACE9 back; LPDIRECT3DSURFACE9 bbuffer; bbuffer = LoadSurface("background.bmp", NULL); // this call creates an unresolved external symbol error HRESULT result; result = d3ddev->StretchRect(back, NULL, bbuffer, NULL, D3DTEXF_NONE); if (result != D3D_OK) { MessageBox(hwnd, "Error with clearing backbuffer", "Error", MB_OK); } d3ddev->Present(NULL, NULL, NULL, NULL); return 1; } The error is shown as: Error 20 error LNK2019: unresolved external symbol "public: struct IDirect3DSurface9 * __thiscall DisplayManager::LoadSurface(char *,unsigned long)" (?LoadSurface@DisplayManager@@QAEPAUIDirect3DSurface9@@PADK@Z) referenced in function "public: int __thiscall DisplayManager::Draw(struct HWND__ *)" (?Draw@DisplayManager@@QAEHPAUHWND__@@@Z) DisplayManager.obj I have tried declaring the LoadSurface function before the Draw function, but to no avail. Why would a function in the same class be not found by another function in the same class?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this