Recommended Posts

I've had this error for 2 days now I'm about to lose the plot!
error LNK2005: "struct IDirectInputDevice8A * InputDevice" already defined in...
and
error LNK2005: "struct IDirect3DDevice9 * Device" already defined in...
The way my include headers are structured is that d3dx9.h & dinput.h have to be included twice when linking, but I thought the #ifndef statement should mean this wont be a problem?
I've really run out of ideas
?????
Any ideas would be much appreciated.

Share this post

Link to post

Share on other sites

Do not define variables in header files. If you do, each translation unit that includes that header generates a copy of the variable. The linker then sees all those identically-named symbols and tells you it can't do anything with that. it Iis not the linker's job to resolve such conflicts.

Declare the variable in the header file, define it in a (single) source file.