Jump to content
  • Advertisement
Sign in to follow this  
Enerjak

WeirdLinker errors.

This topic is 3661 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've gotten some wierd linker error fromk the examples i got from the Book Into to Direct3D 9 a shader approtch. it seems that the sprite demo can't link to a lib because i get these:

1>Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base@std@@QAE@XZ) referenced in function "public: __thiscall std::_List_nod<struct BulletInfo,class std::allocator<struct BulletInfo> >::~_List_nod<struct BulletInfo,class std::allocator<struct BulletInfo> >(void)" (??1?$_List_nod@UBulletInfo@@V?$allocator@UBulletInfo@@@std@@@std@@QAE@XZ)
1>Hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::_Container_base(void)" (__imp_??0_Container_base@std@@QAE@XZ) referenced in function "protected: __thiscall std::_List_nod<struct BulletInfo,class std::allocator<struct BulletInfo> >::_List_nod<struct BulletInfo,class std::allocator<struct BulletInfo> >(class std::allocator<struct BulletInfo>)" (??0?$_List_nod@UBulletInfo@@V?$allocator@UBulletInfo@@@std@@@std@@IAE@V?$allocator@UBulletInfo@@@1@@Z)
1>C:\Documents and Settings\DirectX\My Documents\Visual Studio 2008\Projects\D3DFrameWork\Debug\D3DFrameWork.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\DirectX\My Documents\Visual Studio 2008\Projects\D3DFrameWork\D3DFrameWork\Debug\BuildLog.htm"
1>D3DFrameWork - 3 error(s), 0 warning(s)


any ideas on why i get these will greatly help. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Linker errors are tricky to figure out, and I have by no means figured it out, but I have had the same kind of error before. One of the destructors in a class of yours might be written ~name();

I think an unresolved external has to do with things from one set of .cpp/.h files to another, like an extern'd vector of structs. I dont get why the compiler doesnt cathc it exactly...

that one gave me an error until i changed it to ~name(){}
and it works just fine. Hope it works.

Share this post


Link to post
Share on other sites
well here is my code from the sprite demo, it's kind of long, so bare with me on this.




#include "Bin/d3dApp.h"
#include <tchar.h>
#include <crtdbg.h>
#include <fstream>
#include <list>
#include "Bin/GfxStats.h"
#include "Bin/DirectInput.h"

using namespace std;


ofstream File("DisplayModes.mode");
ofstream MultiSample("MultiSampling.multi");

struct BulletInfo
{
D3DXVECTOR3 pos;
float rotation;
float life;
};

class HelloD3DApp : public D3DApp
{
public:
HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP);
~HelloD3DApp(){};

bool checkDeviceCaps();
void onLostDevice();
void onResetDevice();
void updateScene(float dt);
void drawScene();
void SaveDisplayModes();
void SaveMultiSamplingTofile();

//Helper Functions.
void UpdateShip(float dt);
void UpdateBullets(float dt);
void drawBkgd();
void drawShip();
void drawBullets();

private:

GfxStats* mGfxStats;

ID3DXSprite* mSprites;

IDirect3DTexture9* mBkgTex;
D3DXVECTOR3 mBkgCenter;

IDirect3DTexture9* mShipTex;
D3DXVECTOR3 mShipPos;
D3DXVECTOR3 mShipCenter;
float mShipSpeed;
float mShipRotation;

IDirect3DTexture9* mBulletTex;
D3DXVECTOR3 mBulletCenter;
list<BulletInfo> mBulletList;

const float BULLET_SPEED;
const float MAX_SHIP_SPEED;
const float SHIP_DRAG;
const float SHIP_ACCEL;


};

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance,
PSTR cmdLine, int showCmd)
{
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif


HelloD3DApp app(hInstance, "Hello Direct3D", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);
app.SaveDisplayModes();
app.SaveMultiSamplingTofile();
gd3dApp = &app;

DirectInput di(DISCL_NONEXCLUSIVE|DISCL_FOREGROUND, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND);
gDInput = &di;

return gd3dApp->run();
}

HelloD3DApp::HelloD3DApp(HINSTANCE hInstance, std::string winCaption, D3DDEVTYPE devType, DWORD requestedVP)
: D3DApp(hInstance, winCaption, devType, requestedVP),BULLET_SPEED(2500.0f), MAX_SHIP_SPEED(1500.0f),
SHIP_ACCEL(1000.0f), SHIP_DRAG(0.85f)
{
srand(time_t(0));

if(!checkDeviceCaps())
{
MessageBox(0, "checkDeviceCaps() Failed", 0, 0);
PostQuitMessage(0);
}

mGfxStats = new GfxStats();

HR(D3DXCreateSprite(gd3dDevice,&mSprites));

HR(D3DXCreateTextureFromFile(
gd3dDevice,"bkgd1.bmp",&mBkgTex));
HR(D3DXCreateTextureFromFile(
gd3dDevice,"alienship.bmp",&mShipTex));
HR(D3DXCreateTextureFromFile(
gd3dDevice,"bullet.bmp",&mBulletTex));

mBkgCenter = D3DXVECTOR3(256.0f,256.0,0);
mShipCenter = D3DXVECTOR3(64.0, 64.0,0);
mBulletCenter = D3DXVECTOR3(32.0,32.0,0);

onResetDevice();




}

HelloD3DApp::~HelloD3DApp()
{
delete mGfxStats;
ReleaseCOM(mSprites);
ReleaseCOM(mBkgTex);
ReleaseCOM(mShipTex);
ReleaseCOM(mBulletTex);

}

void HelloD3DApp::SaveMultiSamplingTofile()
{




}

void HelloD3DApp::SaveDisplayModes()
{
D3DDISPLAYMODE Mode;
for (int i = 0; i < GetDirect3D9()->GetAdapterCount(); i++)
{
UINT modes = GetDirect3D9()->GetAdapterModeCount(
i,D3DFMT_X8R8G8B8);

for(int j = 0; j < modes; j++)
{
GetDirect3D9()->EnumAdapterModes(i,
D3DFMT_X8R8G8B8,j,&Mode);

File << "Width = " << Mode.Width << " ";
File << "Height = " << Mode.Height << " ";
File << "Format = " << Mode.Format << " ";
File << "Refresh Rate = " << Mode.RefreshRate << endl;
}
}
}



bool HelloD3DApp::checkDeviceCaps()
{



// Nothing to check.
return true;
}

void HelloD3DApp::onLostDevice()
{
mGfxStats->onLostDevice();
mSprites->OnLostDevice();
}

void HelloD3DApp::onResetDevice()
{
mGfxStats->onResetDevice();
mSprites->OnResetDevice();

D3DXMATRIX V;
D3DXVECTOR3 pos(0,0,-1000);
D3DXVECTOR3 Up(0.0,1.0,0.0);
D3DXVECTOR3 Target(0,0,0);
D3DXMatrixLookAtLH(&V,&pos,&Target,&Up);
gd3dDevice->SetTransform(D3DTS_VIEW,&V);

D3DXMATRIX P;
RECT R;
GetClientRect(mhMainWnd,&R);
float width = (float)R.right;
float height = (float)R.bottom;
D3DXMatrixPerspectiveLH(&P,45.0,width/height,1.0,5000.0);
gd3dDevice->SetTransform(D3DTS_PROJECTION,&P);

HR(gd3dDevice->SetSamplerState(
0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR));
HR(gd3dDevice->SetSamplerState(
0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR));
HR(gd3dDevice->SetSamplerState(
0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR));

HR(gd3dDevice->SetRenderState(D3DRS_LIGHTING,false));

HR(gd3dDevice->SetRenderState(D3DRS_ALPHAREF,10));
HR(gd3dDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATER));

HR(gd3dDevice->SetTextureStageState(
0, D3DTSS_ALPHAARG1,D3DTA_TEXTURE));
HR(gd3dDevice->SetTextureStageState(
0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1));

HR(gd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA));
HR(gd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA));
HR(gd3dDevice->SetTextureStageState(0,
D3DTSS_TEXTURETRANSFORMFLAGS,D3DTTFF_COUNT2));
}

void HelloD3DApp::updateScene(float dt)
{
mGfxStats->setTriCount(4 + mBulletList.size()*2);
mGfxStats->setVertexCount(8 + mBulletList.size()*4);
mGfxStats->upDate(dt);

gDInput->poll();

UpdateShip(dt);
UpdateBullets(dt);

}

void HelloD3DApp::UpdateShip(float dt)
{
if(gDInput->keyDown(DIK_A)) mShipRotation += 4.0f * dt;
if(gDInput->keyDown(DIK_D)) mShipRotation -= 4.0f * dt;
if(gDInput->keyDown(DIK_W)) mShipSpeed += SHIP_ACCEL * dt;
if(gDInput->keyDown(DIK_S)) mShipSpeed -= SHIP_ACCEL * dt;

if(mShipSpeed > MAX_SHIP_SPEED)
mShipSpeed = MAX_SHIP_SPEED;
if(mShipSpeed < -MAX_SHIP_SPEED)
mShipSpeed = -MAX_SHIP_SPEED;

D3DXVECTOR3 ShipDir(-sinf(mShipRotation),
cosf(mShipRotation),0);

mShipPos += ShipDir * mShipSpeed * dt;
mShipSpeed -= SHIP_DRAG * mShipSpeed * dt;
}

void HelloD3DApp::UpdateBullets(float dt)
{
static float fireDelay = 0.0f;

fireDelay += dt;

if(gDInput->keyDown(DIK_SPACE) && fireDelay > 0.0f)
{
BulletInfo Bulletinfo;

Bulletinfo.pos = D3DXVECTOR3(0,0,0);

Bulletinfo.rotation = mShipRotation;

Bulletinfo.life = 0.0f;

mBulletList.push_back(Bulletinfo);

fireDelay = 0.0f;
}
list<BulletInfo>::iterator i = mBulletList.begin();
while(i != mBulletList.end())
{
i->life += dt;

if(i->life >= 2.0f)
i = mBulletList.erase(i);
else
{
D3DXVECTOR3 Dir(
-sinf(i->rotation),
cosf(i->rotation),
0);
i->pos += Dir * BULLET_SPEED * dt;
++i;
}
}
}



void HelloD3DApp::drawScene()
{
HR(gd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0));


HR(gd3dDevice->BeginScene());

HR(mSprites->Begin(D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_DONOTMODIFY_RENDERSTATE));

drawBkgd();
drawShip();
drawBullets();

mGfxStats->display();

HR(mSprites->End());

HR(gd3dDevice->EndScene());
HR(gd3dDevice->Present(0, 0, 0, 0));
}

void HelloD3DApp::drawBkgd()
{
D3DXMATRIX TexScaling;
D3DXMatrixScaling(&TexScaling, 10.0, 10.0,0);
HR(gd3dDevice->SetTransform(D3DTS_TEXTURE0,&TexScaling));

D3DXMATRIX T, S;
D3DXMatrixTranslation(&T, -mShipPos.x, -mShipPos.y, -mShipPos.z);
D3DXMatrixScaling(&S,20,20,0);
HR(mSprites->SetTransform(&(S * T)));

HR(mSprites->Draw(HelloD3DApp::mBkgTex,0,&mShipCenter, 0,
D3DCOLOR_XRGB(255,255,255)));

HR(mSprites->Flush());

D3DXMatrixScaling(&TexScaling, 1.0,-1.0,0);
HR(gd3dDevice->SetTransform(D3DTS_TEXTURE0,&TexScaling));
}



void HelloD3DApp::drawShip()
{
// Turn on the alpha test.
HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, true));

// Set ships orientation.
D3DXMATRIX R;
D3DXMatrixRotationZ(&R, mShipRotation);
HR(mSprites->SetTransform(&R));

// Draw the ship.
HR(mSprites->Draw(mShipTex, 0, &mShipCenter, 0, D3DCOLOR_XRGB(255, 255, 255)));
HR(mSprites->Flush());

// Turn off the alpha test.
HR(gd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, false));
}

void HelloD3DApp::drawBullets()
{
// Turn on alpha blending.
HR(gd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true));

// For each bullet...
std::list<BulletInfo>::iterator i = mBulletList.begin();
while( i != mBulletList.end() )
{
// Set its position and orientation.
D3DXMATRIX T, R;
D3DXMatrixRotationZ(&R, i->rotation);
D3DXMatrixTranslation(&T, i->pos.x, i->pos.y, i->pos.z);
HR(mSprites->SetTransform(&(R*T)));

// Add it to the batch.
HR(mSprites->Draw(mBulletTex, 0, &mBulletCenter, 0, D3DCOLOR_XRGB(255, 255, 255)));
++i;
}
// Draw all the bullets at once.
HR(mSprites->Flush());

// Turn off alpha blending.
HR(gd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, false));
}




As you can see, that's my code, of course that's the code i got from the book that i bought so it's not really my style. All i know is that those two linker errors are keeping me from compiling :-(

Share this post


Link to post
Share on other sites
those " " includes with the bins, do those files exist on your comp? In not, Id be willing to bet thats the problem.

There is series of calls to ReleaseCOM(); in the destructor, but no function body of it. the d3dapp.h would likely be the header with something like that, which is just a safe release (dont want to ->Release() twice)

Share this post


Link to post
Share on other sites
yeah they are in my project file in a folder called Bin. maybe that's the problem but i don't think so, as usual i'll have to see what i can do my self :-\

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!