User forums > Using Code::Blocks

Codeblocks 12.11 LNK2005 errors using VS 2010

(1/4) > >>

Mug:
I'm attempting to compile the automatic generated wxWidgets program in codeblocks 12.11 with the compiler set to Visual Studio 2010 on Windows 7 but receive loads of link errors:


--- Code: ---msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmtd.lib(xthrow.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmtd.lib(xthrow.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in Test2App.obj|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in Test2Main.obj|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in Test2App.obj|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z) already defined in libcpmtd.lib(stdthrow.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in libcpmtd.lib(xlock.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: virtual __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmtd.lib(cout.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "protected: __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::basic_streambuf<char,struct std::char_traits<char> >(void)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in libcpmtd.lib(cout.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::clear(int,bool)" (?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in libcpmtd.lib(cout.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: virtual __thiscall std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmtd.lib(cout.obj)|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: virtual __thiscall std::basic_ostream<char,struct std::char_traits<char> >::~basic_ostream<char,struct std::char_traits<char> >(void)" (??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ) already defined in libcpmtd.lib(cout.obj)|
etc.

--- End code ---

I've read this can be solved by setting the /NODEFAULTLIB:library flag but I haven't found where to set this in 12.11. How can I get the program to link correctly?

cacb:
You can do it as shown in the attachment, which shows a Release target. For the Debug target remove the 'd's in the library names.

Mug:
Thanks, I'm slowly getting there... However, I'm still getting some errors.

These are my current settings:
Settings->Compiler...->Search Directories->Compiler
  C:\Program Files\Microsoft SDKs\Windows\v7.1\Include
  C:\Program Files\Microsoft Visual Studio 10.0\VC\include

Settings->Compiler...->Search Directories->Linker
  C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib
  C:\Program Files\Microsoft Visual Studio 10.0\VC\lib

Settings->Compiler...->Search Directories->Resource Compiler
  C:\Program Files\Microsoft SDKs\Windows\v7.1\Include
  C:\Program Files\Microsoft Visual Studio 10.0\VC\include
  
Settings->Compiler...->Linker settings->Other linker options:
    /NODEFAULTLIB:libcpmtd.lib
    /NODEFAULTLIB:LIBCMTD.lib

These are my steps to produce the errors
1. Start codeblocks 12.11.
2. Click "Create a new project".
3. Double click "wxWidgets Project".
4. Select wxWidgets 2.9.x (SVN Version).
5. Click "Next".
6. Enter Project title: "Test2".
7. Click "Next".
8. Click "Next*.
9. Select "wxSmith" and "Dialog Based".
10. Click "Next".
11. Accept wxWidgets' location: as "$(#wx)".
12. Click "Next".
13. Compiler is "Microsoft Visual C++ 2010 and both "Release" and "Debug" boxes are checked.
14. Click "Next".
15. Only "Enable Unicode" is checked.
16. Click "Next".
17. On the messagebox, click "No" to continue with Multi-threaded Static CRT mode.
18. Select wxHTML, wxJpeg and wxTiff.
19. Click "Finish".
20. Build the application.

These are the errors I get  ???

--- Code: ---msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in Test2App.obj|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: __thiscall std::_Container_base12::_Container_base12(void)" (??0_Container_base12@std@@QAE@XZ) already defined in Test2Main.obj|
msvcprtd.lib(MSVCP100D.dll)||error LNK2005: "public: void __thiscall std::_Container_base12::_Orphan_all(void)" (?_Orphan_all@_Container_base12@std@@QAEXXZ) already defined in Test2App.obj|
bin\Debug\Test2.exe||fatal error LNK1169: one or more multiply defined symbols found|

--- End code ---

cacb:

--- Quote from: Mug on February 21, 2013, 09:41:49 am ---Thanks, I'm slowly getting there... However, I'm still getting some errors.

--- End quote ---

Because you didn't follow the previous advice as shown.

Mug:

--- Quote from: cacb on February 21, 2013, 07:52:58 pm ---
Because you didn't follow the previous advice as shown.

--- End quote ---

Could you be more specific?
Of course I tried with all the files you showed in the "Other linker options", but since I got the same errors, I see no point in keeping them there. Anyway, I put them back in and I still get the errors.

[attachment deleted by admin]

Navigation

[0] Message Index

[#] Next page

Go to full version