0
votes

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

4
did you modify your compiler paths or add extra libraries?A.Rashad

4 Answers

3
votes

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.

2
votes

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.

0
votes

probably you added a similar library to additional libraries.

0
votes

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