title: NODEFAULTLIB nightmare in VS2010 C++ project: links fine in debug, can't find a consistent set of libraries in release
body: <p>Overflowers!</p>
  
  <p>I've been developing a statically-linked application using Visual Studio 2010 (well, it's cross-platform, but this is just a Windows issue).</p>
  
  <p>I had few issues setting up the linking for the Debug configuration, so I didn't expect it would be hard to change it to make a Release configuration, but after an afternoon's work it's still eluding me.  Trying various values for NODEFAULTLIB either get me "unresolved external symbol" errors or "already defined in" errors and sometimes both.</p>
  
  <p>From my notes, I've tried NODEFAULTLIB-ing LIBCMT, MSVCRT, MSVCPRT, or none at all, with different results each time (see below for details).</p>
  
  <p>Now, my Debug configuration uses /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:MSVCPRTD and that works fine, so you'd think that /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:MSVCPRT would work for the Release configuration.  And the fact that it doesn't is a red flag for me...</p>
  
  <p>I'm linking with several other libraries - I was pretty careful to systematically make sure that they were considered exactly the same when going from Debug to Release but could that conceivably be an issue, and if so how to track it down systematically?</p>
  
  <p>Thanks for your gracious time!</p>
  
  <p>In the Linker/Command Line property page, All Options is:</p>
  
  <pre><code> /OUT:".\Release\SlowGold 8.exe" /NOLOGO "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /MANIFEST /ManifestFile:".\Release\SlowGold 8.exe.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /PDB:".\Release\SlowGold 8.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /PGD:"C:\development\rec-vs\rec\projects\slow\Builds\VisualStudio2010\Release\SlowGold 8.pgd" /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:QUEUE 
  </code></pre>
  
  <p>and Additional Options is:</p>
  
  <pre><code>/LIBPATH:..\\..\\..\\..\\externals\\rubberband\\win32\\ipp\\common ippacemerged.lib ippacmerged.lib ippcorel.lib ippsemerged.lib ippsmerged.lib ippsremerged.lib ippsrmerged.lib /LIBPATH:..\\..\\..\\..\\externals\\rubberband\\win32\\ipp\\release\\static rubberband-library.lib /LIBPATH:..\\..\\..\\..\\..\\glog\\Release libglog_static.lib /LIBPATH:..\\..\\..\\..\\..\\mpg123\\ports\\MSVC++\\2008\\Release libmpg123.lib /LIBPATH:..\\..\\..\\..\\..\\protobuf\\vsprojects\\Release libprotobuf.lib 
  </code></pre>
  
  <p>And here are some error messages for various /NODEFAULTLIB: values.</p>
  
  <p>Best so far: /NODEFAULTLIB:LIBCMT</p>
  
  <pre><code>1&gt;------ Build started: Project: Slow, Configuration: Release Win32 ------
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __thiscall std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;(class std::basic_streambuf&lt;char,struct std::char_traits&lt;char&gt; &gt; *,bool)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z) already defined in libcpmt.lib(cerr.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;.\Release\SlowGold 8.exe : fatal error LNK1169: one or more multiply defined symbols found
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>Another attempt with only /NODEFAULTLIB:MSVCRT</p>
  
  <pre><code>1&gt;------ Build started: Project: Slow, Configuration: Release Win32 ------
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __thiscall std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;(class std::basic_streambuf&lt;char,struct std::char_traits&lt;char&gt; &gt; *,bool)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z) already defined in libcpmt.lib(cerr.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp__strncat
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp__perror
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp___pclose
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl _open(char const *,int,int)" (__imp_?_open@@YAHPBDHH@Z)
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp___access
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp___popen
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp___wassert
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp__fdopen
  1&gt;OLDNAMES.lib(fdopen.obi) : error LNK2001: unresolved external symbol __imp__fdopen
  1&gt;libglog_static.lib(logging.obj) : error LNK2001: unresolved external symbol __imp__unlink
  1&gt;OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp__unlink
  1&gt;libglog_static.lib(utilities.obj) : error LNK2001: unresolved external symbol __imp___getpid
  1&gt;libglog_static.lib(port.obj) : error LNK2001: unresolved external symbol __imp___vsnprintf
  1&gt;libprotobuf.lib(message.obj) : error LNK2001: unresolved external symbol __imp__ldiv
  1&gt;libprotobuf.lib(descriptor.obj) : error LNK2001: unresolved external symbol __imp__ldiv
  1&gt;libprotobuf.lib(extension_set.obj) : error LNK2001: unresolved external symbol __imp__ldiv
  1&gt;libprotobuf.lib(common.obj) : error LNK2001: unresolved external symbol __imp___snprintf
  1&gt;libprotobuf.lib(strutil.obj) : error LNK2001: unresolved external symbol __imp___snprintf
  1&gt;OLDNAMES.lib(fdopen.obi) : error LNK2001: unresolved external symbol __imp___fdopen
  1&gt;OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp___unlink
  1&gt;.\Release\SlowGold 8.exe : fatal error LNK1120: 15 unresolved externals
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>Without /NODEFAULTLIB:</p>
  
  <pre><code>1&gt;------ Build started: Project: Slow, Configuration: Release Win32 ------
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: __thiscall std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt;(class std::basic_streambuf&lt;char,struct std::char_traits&lt;char&gt; &gt; *,bool)" (??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z) already defined in libcpmt.lib(cerr.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;msvcprt.lib(MSVCP100.dll) : error LNK2005: "void __cdecl std::_Xout_of_range(char const *)" (?_Xout_of_range@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __stricmp already defined in LIBCMT.lib(stricmp.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strerror_s already defined in LIBCMT.lib(strerror.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fflush already defined in LIBCMT.lib(fflush.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strtol already defined in LIBCMT.lib(strtol.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strrchr already defined in LIBCMT.lib(strrchr.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __write already defined in LIBCMT.lib(write.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __close already defined in LIBCMT.lib(close.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &amp;)" (??0exception@std@@QAE@ABQBD@Z) already defined in LIBCMT.lib(stdexcpt.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) already defined in LIBCMT.lib(stdexcpt.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMT.lib(memmove.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &amp;)" (??0exception@std@@QAE@ABV01@@Z) already defined in LIBCMT.lib(stdexcpt.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _printf already defined in LIBCMT.lib(printf.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _fprintf already defined in LIBCMT.lib(fprintf.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: ___iob_func already defined in LIBCMT.lib(_file.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _abort already defined in LIBCMT.lib(abort.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memchr already defined in LIBCMT.lib(memchr.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __strtoi64 already defined in LIBCMT.lib(strtoq.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __strtoui64 already defined in LIBCMT.lib(strtoq.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strtoul already defined in LIBCMT.lib(strtol.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __errno already defined in LIBCMT.lib(dosmap.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strerror already defined in LIBCMT.lib(strerror.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strchr already defined in LIBCMT.lib(strchr.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _sprintf already defined in LIBCMT.lib(sprintf.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strtod already defined in LIBCMT.lib(strtod.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: _strpbrk already defined in LIBCMT.lib(strpbrk.obj)
  1&gt;MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &amp;)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
  1&gt;MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info &amp; __thiscall type_info::operator=(class type_info const &amp;)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj)
  1&gt;MSVCRT.lib(MSVCR100.dll) : error LNK2005: __read already defined in LIBCMT.lib(read.obj)
  1&gt;LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
  1&gt;.\Release\SlowGold 8.exe : fatal error LNK1169: one or more multiply defined symbols found
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>