Linkage Duplicate Symbols on Windows

Help
GaryK
2005-09-07
2013-04-25
  • GaryK
    GaryK
    2005-09-07

    When linking my application to the Beta version of mxflib I get duplicate symbols for what seem to be the std library. The errors point to mdobject.obj and essence.obj. Can anyone suggest a solution?

     
    • Matt Beard
      Matt Beard
      2005-09-08

      Hi,

      What compiler are you using?

      With which Beta package are you finding this problem?

      What symbols are being reported as duplicate?

       
    • GaryK
      GaryK
      2005-09-08

      Thanks for your quick reply, Matt.

      I am using Visual C++.net version 2003.

      The zip file for mxflib is called mxflib-beta-0.5.1.

      Here are the symbols:
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: char const * __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::c_str(void)const " (?c_str@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPBDXZ) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator+=(char const *)" (??Y?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::max_size(void)const " (?max_size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::erase(unsigned int,unsigned int)" (?erase@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@II@Z) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: unsigned int __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::size(void)const " (?size@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEIXZ) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@ABV01@@Z) already defined in mxflib.lib(essence.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::append(char const *)" (?append@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBD@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::operator=(char const *)" (??4?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV01@PBD@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "bool __cdecl std::operator!=<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?9DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      msvcprtd.lib(MSVCP71D.dll) : warning LNK4006: "bool __cdecl std::operator==<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *)" (??$?8DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YA_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@PBD@Z) already defined in mxflib.lib(mdobject.obj); second definition ignored
      .\Debug\wrapaspa.exe : warning LNK4088: image being generated due to /FORCE option; image may not run

       
      • ppcc81
        ppcc81
        2007-11-30

        I've got the same problem with Visual C++ 6.0, any help???

         
        • Matt Beard
          Matt Beard
          2007-11-30

          With which version of the library do you get this problem?

           
          • ppcc81
            ppcc81
            2007-11-30

            Hello, let me explain what we are doing. We are trying to use MXFlib 1.0.0(10) in a program which already uses wxWidgets 2.8.3 and libopenjpeg 1.2.0, compiled with fully patched VC++ 6. It compiles fine, but now when adding MXF support we are finding linker errors which are unknown to us. For example, just to verify that the library has been correctly linked, we have used the method LibraryVersion().c_str() in order to obtain the lib version. The strange thing is that if we add mxflib.lib in the linker input settings, it fails with msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@
            DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in mxflib.lib(partition.obj)
            msvcprt.lib(MSVCP60.dll) : error LNK2005: "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(char co
            nst *,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEAAV12@PBDI@Z) already defined in mxflib.lib(partition.obj)
            msvcprt.lib(MSVCP60.dll) : error LNK2005: "private: void __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Eos(unsigned int)" (?_Eos@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEXI@Z) a
            lready defined in mxflib.lib(partition.obj)
            msvcprt.lib(MSVCP60.dll) : error LNK2005: "private: bool __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Grow(unsigned int,bool)" (?_Grow@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAE
            _NI_N@Z) already defined in mxflib.lib(partition.obj)

             
            • Matt Beard
              Matt Beard
              2007-11-30

              Ah, you need to ensure that all libraries are compiled with the same options, otherwise you get two versions of various system library items linked in. For example if one library is compiled single thread and another multi-thread you will get the first library trying to link to the single threaded std libs and the other trying to link to the multi-threaded version. It then all goes pear-shaped!

               
              • ppcc81
                ppcc81
                2007-11-30

                Thanks, that did the job!

                 
    • ppcc81
      ppcc81
      2007-11-30

      Well, by removing msvcprt.lib there are far more errors, whereas if mxflib.lib is excluded, it compiles perfectly and gives the lib version at run time! Ehi, where does it get the method from?

       
    • ppcc81
      ppcc81
      2007-11-30

      Moreover, looking at the examples provided in mxflib.dsw, such as mxfsplit, we see that mxflib.lib is not linked but the program compiles. Where is the magic? Thanks in advance for any advice you can give us.

      PS: if we add some more call in the code, such as for example

      MXFFilePtr TestFile = new MXFFile;

      we have errors like

      imagmxf.obj : error LNK2001: unresolved external symbol "protected: virtual unsigned int __thiscall mxflib::MXFFile::MemoryRead(unsigned char *,unsigned int)" (?MemoryRead@MXFFile@mxflib@@MAEIPAEI@Z)
      imagmxf.obj : error LNK2001: unresolved external symbol "protected: virtual unsigned int __thiscall mxflib::MXFFile::MemoryWrite(unsigned char const *,unsigned int)" (?MemoryWrite@MXFFile@mxflib@@MAEIPBEI@Z)
      imagmxf.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall mxflib::MXFFile::Close(void)" (?Close@MXFFile@mxflib@@UAE_NXZ)
      ...

      as it expects the methods provided by the lib