Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. LNK4006 - double definition ?!

LNK4006 - double definition ?!

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Brainley
    wrote on last edited by
    #1

    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.

    C 1 Reply Last reply
    0
    • M Mr Brainley

      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.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      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.

      image processing | blogging

      M 1 Reply Last reply
      0
      • C Chris Losinger

        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.

        image processing | blogging

        M Offline
        M Offline
        Mr Brainley
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • M Mr Brainley

          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.

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          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?

          image processing | blogging

          M 1 Reply Last reply
          0
          • C Chris Losinger

            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?

            image processing | blogging

            M Offline
            M Offline
            Mr Brainley
            wrote on last edited by
            #5

            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 ...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups