"fatal error LNK1169: one or more multiply defined symbols found"
Hello all,
I've been dealing with this error for a bit, and as much as I attempt to error trap the bugger, I can't find where it's being caused from. There is a good chance that I'm missing a very simple answer, but even if it is - it's driving me nuts.
The error I am referring to is the dreaded:
fatal error LNK1169: one or more multiply defined symbols found
.
I'm aware of what this error GENERALLY means, but I can not for the life of me understand why I am still getting it.
The full error is:
error LNK2005: "class COORDINATES * Game_Player::coordinates" (?coordinates@Game_Player@@$$Q3PAVCOORDINATES@@A) already defined in Roleplaying game.obj
G:\Program\Roleplaying game\Debug\Roleplaying game.exe : fatal error LNK1169: one or more multiply defined symbols found
Because of the size of my project, I won't be able to show the entire thing of code, but I will isolate where the errors are all coming from.
The definition of class COORDINATES, as stated in the error above, comes from this (this is just the definition, because the whole thing normally has many more declarations)
Normally I don't use both #pragma once and #ifndef; I normally just use the #ifndef for my safegaurding, but because of the annoying error that I keep receiving, I have tried adding both - to which I continue to receive the error.
At the present moment in time, these are the only 2 files in my project (save for the file for the form, which contains no declaration of "POSITION", "COORDINATES", etc..
In an attempt to check for this error, I have already commented out nearly all pre-existing code, I have already tried renaming the variable above to make sure it's not a naming error, to which the likes of "MY_REALLY_RANDOMLY_NAMED_VARIABLE" still contains the error.
I have also tried changing the namespace to a class, and - for some bizarre reason - doing so temporarily completely removed the error. If this were an unnamed namespace, I could understand the error, but the fact that i have given it a name is what confuses me.
The only thing I can think of is that it's the included order of the header files (because the main form also contains include for the two of them to make them part of the system). I know that the stdafx file is for including other headers, but I'm not sure if that is exactly where I'm supposed to go because, prior to this project, my work always remained in pure console where I designed all the code and didn't use pre-made code.
It's likely an error so simple that I have overlooked it, but it's been driving me up the wall for some time (normally I just comment it out and it will run fine without it because it's not used, at the moment)
If someone could help me and has endured the long grueling explanation, I would really appreciate the aide.
Thanks in advance to all who offer their help :P
~TheDiabolicalPupeteer
Edit 1:
Sorry if the code shows up messed up. The tabbing on this forum is different from in my compiler, which my code is really neat.
Another note: I think spoilers would be useful in this forum for adding code inside.
Edit 2:
I forgot to mention that this error occurs with any of my defined classes or templates, but it appears to only happen in this header (perhaps because of the namespace issue mentioned above?)
I also forgot to mention that I am using Microsoft Visual Studio 2008 (though I doubt it is compiler error, it's likely an oversight on my part).
Another thing I'd like to note is that if the required files are to be included into the stdafx file, that I don't know which ones to include into them - and so if someone could offer some insight into that at the same time, I'd appreciate it.
Last edited by TheDiabolicalPupeteer; June 7th, 2010 at 09:16 PM.
Bookmarks