0

i'm following a book on how to program with driectx 11 but i still got 3 error even though i've programmed it to be exactly the same and checked for diffrences for almost a full day now. i've got 3 errors

error LNK1120: 1 unresolved externals   C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\Debug\TestX engine.exe   1   1   TestX engine
Error   2   error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)    C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\Box.obj TestX engine
Error   1   error LNK2005: _WinMain@16 already defined in Box.obj   C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\InitDirect3D.obj    TestX engine

and my code for the app is:

class BoxApp : public Framework_App
{
public:
    BoxApp(HINSTANCE hInstance);
    ~BoxApp();

bool Init();
void OnResize();
void UpdateScene( float dt);
void DrawScene();
void OnMouseDown(WPARAM btnState, int x, int y);
void OnMouseUp(WPARAM btnState, int x, int y);
void OnMouseMove(WPARAM btnState, int x, int y);

private:
void BuildGeometryBuffers();
void BuildFX();
void BuildVertexlayout();

ID3D11Buffer* mBoxVB;
ID3D11Buffer* mBoxIB;
ID3DX11Effect* mFX;
ID3DX11EffectTechnique* mTech;
ID3DX11EffectMatrixVariable* mfxWorldViewProj;
ID3D11InputLayout* inputLayout;

XMFLOAT4X4 mWorld;
XMFLOAT4X4 mView;
XMFLOAT4X4 mProj;

float mTheta, mPhi, mRadius;
POINT mLastMousePos;
};

the problem should be somewhere around these parts, but i can't find them:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevhInstance, PSTR cmdLine, int showCmd){
BoxApp theApp(hInstance);
if (!theApp.Init())
{
    return 0;
}

return theApp.App_Run();

}

and:

void BoxApp::BuildFX()
{
DWORD shaderFlags = 0;
ID3D10Blob * compiledShader;
ID3D10Blob * compiledShaderMsgs;
HRESULT hr = D3DX11CompileFromFile((LPSTR)"mColor.fx", 0, 0, 0, "fx_5_0", shaderFlags, 0, 0, &compiledShader, &compiledShaderMsgs, 0);

if (compiledShaderMsgs != 0)
{
    MessageBoxA(0, (char*)compiledShaderMsgs->GetBufferPointer(), 0, 0);
    ReleaseCOM(compiledShaderMsgs);
}

D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);
ReleaseCOM(compiledShader);

mTech = mFX->GetTechniqueByName("ColorTech");
mfxWorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
}

in the second bit in particulary this: D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);

thank you beforehand, i really appreciate it.

PVermillion
  • 11
  • 1
  • 3
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?: Failure to link against appropriate libraries/object files or compile implementation files](http://stackoverflow.com/a/12574400/902497) [This duplicate question](http://stackoverflow.com/questions/16642989/dx11-unresolved-externals) tells you what library you need. – Raymond Chen Sep 13 '14 at 20:04
  • I've managed to solve one error but the second one i can't solve. i don't know what the error means and its nowhere to be found. so do you perhaps know what it means? – PVermillion Sep 20 '14 at 20:18
  • Your second problem arises from having defined two entrypoints. The linker has found one in Box.obj, and a second in InitDirect3D.obj. You need to open up InitDirect3D.cpp, find the WinMain function there, and either delete it, combine it with the one in Box.obj, or delete the one in Box.obj. – Alex Oct 10 '14 at 15:44

0 Answers0