C++ linker unresolved external symbols
<p>I'm building an application against some legacy, third party libraries, and having problems with the linking stage.  I'm trying to compile with Visual Studio 9.  My compile command is:</p>

<blockquote>
  <p>cl -DNT40 -DPOMDLL -DCRTAPI1=<em>cdecl
  -DCRTAPI2=cdecl -D</em>WIN32 -DWIN32 -DWIN32<em>LEAN</em>AND<em>MEAN -DWNT -DBYPASS</em>FLEX -D_INTEL=1 -DIPLIB=none -I. -I"D:\src\include" -I"C:\Program Files\Microsoft Visual Studio
  9.0\VC\include" -c -nologo -EHsc -W1 -Ox -Oy- -MD mymain.c</p>
</blockquote>

<p>The code compiles cleanly.  The link command is:</p>

<blockquote>
  <p>link -debug -nologo -machine:IX86
  -verbose:lib -subsystem:console mymain.obj wsock32.lib advapi32.lib
  msvcrt.lib oldnames.lib kernel32.lib
  winmm.lib [snip large list of
  dependencies] D:\src\lib\app_main.obj
  -out:mymain.exe</p>
</blockquote>

<p>The errors that I'm getting are:</p>

<blockquote>
  <p>app<em>main.obj : error LNK2019:
  unresolved external symbol
  "</em>_declspec(dllimport) public: void
  <strong>thiscall std::locale::facet::<em>Register(void)"
  (</strong>imp</em>?<em>Register@facet@locale@std@@QAEXXZ)
  referenced in function "class
  std::ctype const &amp; _</em>cdecl
  std::use<em>facet
  \>(class std::locale const &amp;)" (??$use</em>facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)</p>
  
  <p>app<em>main.obj : error LNK2019:
  unresolved external symbol
  "<strong>declspec(dllimport)  public: static
  unsigned int _</em>cdecl
  std::ctype::<em>Getcat(class
  std::locale::facet const * *)"
  (</strong>imp</em>?<em>Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z)
  referenced in function "class
  std::ctype const &amp; _</em>cdecl
  std::use<em>facet
  \>(class std::locale const &amp;)" (??$use</em>facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)</p>
  
  <p>app<em>main.obj : error LNK2019:
  unresolved external symbol
  "<strong>declspec(dllimport)  public: static
  unsigned int _</em>cdecl
  std::ctype::<em>Getcat(class
  std::locale::facet const * *)"
  (</strong>imp</em>?<em>Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z)
  referenced in function "class
  std::ctype const &amp;
  _</em>cdecl std::use<em>facet >(class
  std::locale const &amp;)"
  (??$use</em>facet@V?$ctype@G@std@@@std@@YAABV?$ctype@G@0@ABVlocale@0@@Z)</p>
  
  <p>mymain.exe : fatal error LNK1120: 3
  unresolved externals</p>
</blockquote>

<p>Notice that these errors are coming from the legacy code, not my code - app_main.obj is part of the legacy code, while mymain.c is my source.  I've done some searching around, and what that I've read says that this type of error is caused by a mismatch with the -MD switch between my code and the library that I'm linking to.  Since I'm dealing with legacy code, a solution has to come from my environment. It's been a long time since I've done C++ work, and even longer since I've used Visual Studio, so I'm hoping that this is just some ignorance on my part.  Any ideas on how to get these resolved?</p>
