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. ATL / WTL / STL
  4. Linker error using MFC and STL

Linker error using MFC and STL

Scheduled Pinned Locked Moved ATL / WTL / STL
c++helptutorialquestion
3 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.
  • J Offline
    J Offline
    Jambolo
    wrote on last edited by
    #1

    I have a non-MFC project using std::string that is compiled into a library (Confetti.lib). My main project is an MFC project that uses this library. I get the following linker errors: msvcprtd.lib(MSVCP70D.dll) : error LNK2005: "public: __thiscall std::basic_string::~basic_string(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in Confetti.lib(ParticleSystem.obj) msvcprtd.lib(MSVCP70D.dll) : error LNK2005: "public: __thiscall std::basic_string::basic_string(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in Confetti.lib(ParticleSystem.obj) Can anyone tell me why this is happening and how to fix it? Also, if I ignore msvcprtd.lib, then I get lots of dll import/export errors for std::basic_string.

    S 1 Reply Last reply
    0
    • J Jambolo

      I have a non-MFC project using std::string that is compiled into a library (Confetti.lib). My main project is an MFC project that uses this library. I get the following linker errors: msvcprtd.lib(MSVCP70D.dll) : error LNK2005: "public: __thiscall std::basic_string::~basic_string(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in Confetti.lib(ParticleSystem.obj) msvcprtd.lib(MSVCP70D.dll) : error LNK2005: "public: __thiscall std::basic_string::basic_string(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) already defined in Confetti.lib(ParticleSystem.obj) Can anyone tell me why this is happening and how to fix it? Also, if I ignore msvcprtd.lib, then I get lots of dll import/export errors for std::basic_string.

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      What's your code generation for both? Multithreaded, singlethreaded, dll, etc? Steve S

      J 1 Reply Last reply
      0
      • S Steve S

        What's your code generation for both? Multithreaded, singlethreaded, dll, etc? Steve S

        J Offline
        J Offline
        Jambolo
        wrote on last edited by
        #3

        Both are multithreaded. However, I found that linking with the MFC DLL causes linker errors, and linking statically does not. My guess is that for some weird reason (a bug?), the MFC DLLs export some STL symbols.

        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