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:
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.
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?
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 ???
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|
OK, thanks. That just goes to show that I don't have a clue how to set up code::blocks and really would appreciate some help.
So, I started again from scratch and left the Global Compiler Options alone.
Now, instead of 4 errors I get over 50 ???
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|
wxbase29ud.lib(mimetype.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(ipcbase.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(textfile.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(base64.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(mimecmn.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(fileback.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(dde.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(fileconf.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(languageinfo.obj)||error LNK2019: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) referenced in function __ehhandler$??1?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@XZ|
wxbase29ud.lib(regconf.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(stdpaths.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(longlong.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(process.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(debughlp.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(datetimefmt.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(crashrpt.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(stackwalk.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(any.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(xlocale.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(dir.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(wxcrt.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(datetime.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(datstrm.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(mstream.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(convauto.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(timercmn.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(ffile.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(stopwatch.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(variant.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(wfstream.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(hash.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(txtstrm.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(textbuf.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(fmapbase.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(encconv.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(stream.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(platinfo.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(utilsexc.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(registry.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(file.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(filename.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(filesys.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(filefn.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(uri.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(time.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(sysopt.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
wxbase29ud.lib(tokenzr.obj)||error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 21 seconds) ===|
Here are my library settings
That was terribly simple after all the frustration I've had over the last few days.
Now you know that wizard shows that message for a reason. As long as you don't mix & match CRT, you should not see these errors.
For the time being, that will certainly get me started, but, if I dare ask, what steps do I need to take to use static CRT mode?
To build wxwidgets with static CRT, you need to do the following. In Visual Studio click Project -> Properties -> Configuration Properties -> C/C++ -> Runtime Library & select Multi-threaded/Multi-threaded Debug option. Click OK to close dialog. Do this for all projects.
Alternatively in the command prompt add the following to compile it with static CRT.
nmake /f makefile.vc RUNTIME_LIBS=static <Other Options>
Is there any way I can check if the static libraries are there?
You can check it by issuing following command
D:\Projects\Test1\Debug>dumpbin /all Test1.lib | find /i "/DEFAULTLIB"
00000000: 20 20 20 2F 44 45 46 41 55 4C 54 4C 49 42 3A 22 /DEFAULTLIB:"
/DEFAULTLIB:MSVCRTD
/DEFAULTLIB:OLDNAMES
D:\Projects\Test1\Debug>
As you can see this shows static library Test1.lib is dynamically linked against MSVCRTD.lib. In this case if you want to link any app against Test1.lib you have to use /MTd as compiler and linker option.
When Test1.lib is linked against static MSVC runtime, it will show libcmt[d].lib in output.