Jump to content
  • Advertisement
Sign in to follow this  

keep getting this error

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

Hello, tried to compile but got this error, anyone can help? Error 1 error LNK2019: unresolved external symbol "public: __thiscall light::light(void)" (??0light@@QAE@XZ) referenced in function "public: __thiscall directx::directx(struct HWND__ *)" (??0directx@@QAE@PAUHWND__@@@Z) DxManager.obj Error 2 fatal error LNK1120: 1 unresolved externals C:\Users\Kay\Desktop\GAM203 & 204 framework\Ass2_v4\Assignment 23\Debug\Assignment 23.exe

Share this post

Link to post
Share on other sites
That's not a compiler error, it's a linker error. The next step. You aren't linking the required file for that function. Possibly because C:\Users\Kay\Desktop\GAM203 & 204 framework\Ass2_v4\Assignment 23\ isn't in your linker paths.

Share this post

Link to post
Share on other sites
ok somehow i got it bt now it says no appropriate default constructor available.

#include "DxManager.h"
#include <atlbase.h>
#include "Light.h"

directx::directx(HWND hWnd)
t_buffer = 0;
z_buffer = 0;

d3d = Direct3DCreate9(D3D_SDK_VERSION);


ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.hDeviceWindow = hWnd;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;

// create a device class using this information and the info from the d3dpp stuct


d3ddev->SetRenderState(D3DRS_LIGHTING, TRUE); // turn on the 3D lighting
d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE); // turn on the z-buffer
d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50)); // ambient light


meshSpaceship->Release(); // close and release the spaceship mesh


void directx::render()
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);



D3DXMATRIX matView; // the view transform matrix
&D3DXVECTOR3 (0.0f, 8.0f, 16.0f), // the camera position
&D3DXVECTOR3 (0.0f, 0.0f, 0.0f), // the look-at position
&D3DXVECTOR3 (0.0f, 1.0f, 0.0f)); // the up direction
d3ddev->SetTransform(D3DTS_VIEW, &matView); // set the view transform to matView

D3DXMATRIX matProjection; // the projection transform matrix
D3DXToRadian(45), // the horizontal field of view
SCREEN_WIDTH / SCREEN_HEIGHT, // the aspect ratio
1.0f, // the near view-plane
100.0f); // the far view-plane
d3ddev->SetTransform(D3DTS_PROJECTION, &matProjection); // set the projection

static float index = 0.0f; index+=0.03f; // an ever-increasing float value
D3DXMATRIX matRotateY; // a matrix to store the rotation for each triangle
D3DXMatrixRotationY(&matRotateY, index); // the rotation matrix
d3ddev->SetTransform(D3DTS_WORLD, &(matRotateY)); // set the world transform

// draw the spaceship
for(DWORD i = 0; i < numMaterials; i++) // loop through each subset
d3ddev->SetMaterial(&material); // set the material for the subset
if(texture != NULL) // if the subset has a texture (if texture is not NULL)
d3ddev->SetTexture(0, texture); // ...then set the texture

meshSpaceship->DrawSubset(i); // draw the subset


d3ddev->Present(NULL, NULL, NULL, NULL);


void directx::init_graphics()

LPD3DXBUFFER bufShipMaterial;

D3DXLoadMeshFromX(L"d1.x", // load this file
D3DXMESH_SYSTEMMEM, // load the mesh into system memory
d3ddev, // the Direct3D Device
NULL, // we aren't using adjacency
&bufShipMaterial, // put the materials here
NULL, // we aren't using effect instances
&numMaterials, // the number of materials in this model
&meshSpaceship); // put the mesh here

// retrieve the pointer to the buffer containing the material information
D3DXMATERIAL* tempMaterials = (D3DXMATERIAL*)bufShipMaterial->GetBufferPointer();

// create a new material buffer and texture for each material in the mesh
material = new D3DMATERIAL9[numMaterials];
texture = new LPDIRECT3DTEXTURE9[numMaterials];

for(DWORD i = 0; i < numMaterials; i++) // for each material...
material = tempMaterials.MatD3D; // get the material info
material.Ambient = material.Diffuse; // make ambient the same as diffuse
USES_CONVERSION; // allows certain string conversions
// if there is a texture to load, load it
texture = NULL; // if there is no texture, set the texture to NULL


[Edited by - jollyjeffers on December 5, 2008 12:27:27 PM]

Share this post

Link to post
Share on other sites
Help us to help you - exact details along with your analysis are essential for us to correctly determine your problem and offer appropriate solutions or advice.

Where does the compiler give you the error? A default constructor will have no parameters, so you're either explicitly or implicitly trying to call one somewhere else in your code...

I'm moving this to 'For Beginners' as it seems your problems, despite being a DX application, are more general C++ with basic linking/compiling errors. If you get far enough to have DX errors then please feel free to post back in this forum.


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!