Boris Raznikov
Boris Raznikov

Reputation: 2443

C++ Linking problem

I have an error in compiling a project. I'm trying to link to a library I have on windows, using visual studio.

When trying to create the obkect (with new), I get the following error:

Error 2 error LNK2005: "public: __thiscall std::basic_string,class std::allocator >::~basic_string,class std::allocator >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in RMLibV053.lib(Inifile.obj) msvcprtd.lib

I used #ifndef I used disable warning

Upvotes: 0

Views: 372

Answers (4)

Boris Raznikov
Boris Raznikov

Reputation: 2443

As Ferruccio explained before.

I used on the visual studio configuration of project: compiled with the setting to use the dynammic linked run time library : Multi-threaded Debug DLL (/MDd) instead of Multi-threaded Debug (/MTd).

Upvotes: 0

Cătălin Pitiș
Cătălin Pitiș

Reputation: 14341

If PTLibV002.lib was compiled to use C++ library statically linked and your binary uses C++ library as DLL, then this is the linking error you'd receive. This is because PTLibV002.lib will contain the definitions of functions from STL it uses, and your binary contains another definition pointing to the C++ library DLL.

Upvotes: 2

Ferruccio
Ferruccio

Reputation: 100658

It may be that your code is set up to use a different run-time environment (single-threaded, multi-threaded, multi-threaded DLL) than your PTLibV002.lib library when it was built.

Upvotes: 3

ufukgun
ufukgun

Reputation: 7209

probably you added a similar library to additional libraries.

Upvotes: 0

Related Questions