LNK4006 - double definition ?!
-
I have two selfwritten libraries, one of wich uses the other. If just add the first one to the dependecies of the second one without actually using it or including any of the header-files or anything, i get a
LNK4006: symbol already defined in object; second definition ignored
for every single symbol in the first library. Can anyone tell me why that is and what i can do about it ? I'm allways eager to eliminate all warnings.
-
I have two selfwritten libraries, one of wich uses the other. If just add the first one to the dependecies of the second one without actually using it or including any of the header-files or anything, i get a
LNK4006: symbol already defined in object; second definition ignored
for every single symbol in the first library. Can anyone tell me why that is and what i can do about it ? I'm allways eager to eliminate all warnings.
if you make one library dependent on another, VS will merge the the two together so that the second library is contained within the first library. the fix is: you only need to link to the 'parent' library, since it will have a copy of the second library in it already.
-
if you make one library dependent on another, VS will merge the the two together so that the second library is contained within the first library. the fix is: you only need to link to the 'parent' library, since it will have a copy of the second library in it already.
Thank you for the awnser, but that is not the problem. It seems, for what reason god alone knows, that VC.NET actually links the file twice. I add it to my linker dependencies and look at the command line - everything fine. Now i build, and suddenly the command line changed, so that the library is actually linked twice. Don't ask me why, but thats what it does.
-
Thank you for the awnser, but that is not the problem. It seems, for what reason god alone knows, that VC.NET actually links the file twice. I add it to my linker dependencies and look at the command line - everything fine. Now i build, and suddenly the command line changed, so that the library is actually linked twice. Don't ask me why, but thats what it does.
your original post says "If just add the first one to the dependecies of the second one without actually using it..." if you make library A depend on library B, the .LIB for library A will contain the .LIB for library B. you don't have to explicitly link library B at all. but, i repeat myself.
Mr.Brainley wrote:
suddenly the command line changed, so that the library is actually linked twice
what does the command line look like?
-
your original post says "If just add the first one to the dependecies of the second one without actually using it..." if you make library A depend on library B, the .LIB for library A will contain the .LIB for library B. you don't have to explicitly link library B at all. but, i repeat myself.
Mr.Brainley wrote:
suddenly the command line changed, so that the library is actually linked twice
what does the command line look like?
Ok, i was unclear there. By "add to dependencies" i meant explicitly linking it. I added the filename in the "Additional dependencies" column of the linker options in the project properties. But i solved the problem now ... somehow. I gave VC a relative path to .lib-file. That was the problem. He put that path into the LIBPATH commandline-option, added the filename to the files to be linked, and then added the filename plus the absolute path to the files to be linked, so it was in there twice. Nice, eh ? I now added an absolute path to my projects properties instead of the relative one, and it works. Who'd have guessed ...