Jump to content
  • Advertisement
Sign in to follow this  

linking error

This topic is 4372 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

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
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!