Hi all,
I have a project which is using Direct3D and DirectInput. Initially I had all the global variables in the main file, BE1.cpp. This worked fine.
To clean up the code a bit, I added a header file, gv.h, to hold all my variables. This header file is included in 'stdafx.h' - which is included in all .cpp files.
This way of doing it throws up the errors:
1>Building1Explore.obj : error LNK2005: "struct IDirect3D9 * d3d" (?d3d@@3PAUIDirect3D9@@A) already defined in stdafx.obj
1>Building1Explore.obj : error LNK2005: "struct IDirect3DDevice9 * d3ddev" (?d3ddev@@3PAUIDirect3DDevice9@@A) already defined in stdafx.obj
1>Building1Explore.obj : error LNK2005: "struct ID3DXMesh * buildingMesh" (?buildingMesh@@3PAUID3DXMesh@@A) already defined in stdafx.obj
1>Building1Explore.obj : error LNK2005: "unsigned long numMaterials" (?numMaterials@@3KA) already defined in stdafx.obj
1>Building1Explore.obj : error LNK2005: "struct _D3DMATERIAL9 * material" (?material@@3PAU_D3DMATERIAL9@@A) already defined in stdafx.obj
1>DirectInput.obj : error LNK2005: "struct IDirectInput8W * din" (?din@@3PAUIDirectInput8W@@A) already defined in stdafx.obj
1>DirectInput.obj : error LNK2005: "struct IDirectInputDevice8W * dinKeyboard" (?dinKeyboard@@3PAUIDirectInputDevice8W@@A) already defined in stdafx.obj
1>DirectInput.obj : error LNK2005: "struct IDirectInputDevice8W * dinMouse" (?dinMouse@@3PAUIDirectInputDevice8W@@A) already defined in stdafx.obj
1>DirectInput.obj : error LNK2005: "unsigned char * KeyState" (?KeyState@@3PAEA) already defined in stdafx.obj
1>DirectInput.obj : error LNK2005: "struct _DIMOUSESTATE MouseState" (?MouseState@@3U_DIMOUSESTATE@@A) already defined in stdafx.obj
1>C:\Users\Andy\Documents\Visual Studio 2008\Projects\DirectX Files\Building1Explore\Debug\Building1Explore.exe : fatal error LNK1169: one or more multiply defined symbols found
Each error is for each of the variables in gv.h
Any ideas on what could be causing the errors?
Thanks a lot,
Andy