1

When I add the following line to my code:

std::string sFrameTag

I get the following linker error:

Error   34  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 
VFPAnalyzerApi.lib(VFPEvaluation.obj)   msvcprtd.lib

I'm sure sFrameTag is only defined once, I tried using other names for this variable to be sure. I have the following includes: stdio.h, time.h, string.

Can someone please guide it as to what causes this error?

8
  • 1
    Please show us the actual line you added to your code (and maybe some of the code, if it isn't 100+ lines). It can't be std::string sFrameTag, that's missing at least a semicolon, and I suspect there are a few parantheses or other stuff as well. Commented Mar 27, 2013 at 11:39
  • 1
    See cegui.org.uk/phpBB2/viewtopic.php?f=1&t=5445 Commented Mar 27, 2013 at 11:43
  • You may show more detail, incuding the file you define in, and others. Commented Mar 27, 2013 at 11:46
  • sounds like you are linking the same lib twice Commented Mar 27, 2013 at 11:55
  • Since the multiply defined symbol is the std::string destructor I don't see how the code can be to blame. The error is in the compiler/linker/project settings, or maybe the way in which VFPAnalyzerApi.lib was built. Commented Mar 27, 2013 at 11:56

1 Answer 1

1

I too get similar kind of errors when I tried to statically include all needed runtime libraries. Do check that when you are trying to import a library which is linked statically with /MD option you also need to use /MD.

Thanks Niraj Rathi

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Niraj, but can you please explain what exactly I need to do? I'm not sure how to use /MD.. Thank you in advance!!
@user2215359 It depnds on which version of VC++ you are using. But on my version the relavent options are under Project Properties - C/C++ - Code Generation - Runtime Library
OK, so I took a look at the project properties, under C/C++ -> code generation -> runtime Library and changed it from /MDd to /MD and now it works!!! Thanks!! But, can someone please explain what exactly is the meaning of this change? thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.