title: How do I make a static library Release/Debug independent in VS2010 Express?
body: <p>I am programming an application and linking against SDL and OpenGL.  In my code I have the following lines:</p>
  
  <pre><code>#pragma comment(lib, "sdl.lib")
  #pragma comment(lib, "sdlmain.lib")
  #pragma comment(lib, "opengl.lib")
  </code></pre>
  
  <p>This works in Release mode only.  In Debug mode, I receive the following linker error:</p>
  
  <pre><code>libcmt.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: __call_reportfault already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_parameter@@YAXPBG00II@Z) already defined in LIBCMTD.lib(invarg.obj)
  libcmt.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in LIBCMTD.lib(invarg.obj)
  libcpmtd.lib(xdebug.obj) : warning LNK4098: defaultlib 'libcmt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
  </code></pre>
  
  <p>I have compiled SDL from source for my application, so I can control the compiler flags.</p>
  
  <p>When I specify /NODEFAULTLIB:"LIBCMT.LIB" or /NODEFAULTLIB:"LIBCMT" for the project SDLMain, the utility dumpbin.exe still reports the following after compilation for sdlmain.lib:</p>
  
  <pre><code>Linker Directives
  -----------------
  /DEFAULTLIB:"LIBCMT"
  /DEFAULTLIB:"OLDNAMES"
  </code></pre>
  
  <p>These linker directives do not appear when I use dumpbin against the opengl.lib (which came with VS2010 Express).  The opengl.lib works in both Release and Debug modes.  The sdl.lib works in both release and debug modes because, I think, it is a DLL lib and not a static lib.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p>EDIT:</p>
  
  <p>I managed to get it to compile and link by adding /NODEFAULTLIB:LIBCMT.LIB to my own Debug configuration instead of SDLMain.  I also assumed that the OpenGL lib was a static library, but it's not, it's a DLL lib also.</p>