views:

139

answers:

4

Hello,

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

A: 

probably you added a similar library to additional libraries.

ufukgun
No, I added only one
Roman Dorevich
+3  A: 

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.

Ferruccio
no only one is in the system
Roman Dorevich
This is pretty much always the cause of this problem. PTLibV002.lib is probably compiled with the setting to use the statically linked run time library.
KJAWolf
yes I need staticly linked run time library
Roman Dorevich
+2  A: 

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.

Cătălin Pitiș
I comiple it as static. I'm using Visual Studio and defined in the linkage, so i guess that it is not the case.
Roman Dorevich
A: 

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

Roman Dorevich