<p>I've opened an old workspace that is a libray and its test harness. It used to work fine but now doesn't and older versions of the code don't work either with the same errors. I've tried recreating the project and that causes the same errors too. Nothing seems out of order in project settings and the code generated works in the main app.</p>

<p>I've stripped out most of the files and got it down to the bare minimum to generate the error. Unfortunately I can't post the project as this is used in production code.</p>

<p>The LNK2001 linker error I get usually means I've left off a library or forgot to implement a virtual function. However this is part of the standard template library - and is a header at that.</p>

<p>The code that is listed as having the problem in IOCompletionPort.obj doesn't actually use <code>std::string</code> directly, but does call a class that does: <code>Comms::Exception</code> accepts a <code>std::string</code> and the value of <code>GetLastError</code> or <code>WSAGetLastError</code>.</p>

<p>The function mentioned in the error (<code>GetMessage</code>) is implemented, but is a virtual function so other classes can override it if need be. However it appears that the compiler has made it as an Ansi version, but I can't find any options in the settings that would control that. I suspect that might be the problem but since there's very little in the way of options for the library I have no way of knowing for sure. However both projects to specify _MBCS in the compiler options.</p>

<blockquote>
  <p>--------------------Configuration: TestComms - Win32 Debug-------------------- Linking...  Comms.lib(IOCompletionPort.obj)
  : error LNK2001: unresolved external symbol "public: virtual class
  std::basic_string,class
  std::allocator > __thiscall
  Comms::Exception::GetMessageA(void)const " (?GetMessageA@
  Exception@Comms@@UBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
  Debug/TestComms.exe : fatal error LNK1120: 1 unresolved externals 
  Error executing link.exe.</p>
  
  <p>TestComms.exe - 2 error(s), 0 warning(s)</p>
</blockquote>

<p>Any suggestions? I've lost most of the morning to this and don't want to lose most of the afternoon too.</p>

[{'answer_id': 5903, 'author': 'Curt Hagenlocher', 'author_id': 533, 'author_profile': 'https://Stackoverflow.com/users/533', 'pm_score': 4, 'selected': True, 'text': '<p>One possibility lies with Win32 ANSI/Unicode "name-mangling", which turns the symbol <code>GetMessage</code> into either <code>GetMessageA</code> or <code>GetMessageW</code>. There are three possibilities:</p>\n\n<ol>\n<li><p>Windows.h hasn\'t been loaded, so <code>GetMessage</code> stays <code>GetMessage</code></p></li>\n<li><p>Windows.h was loaded with symbols set for ANSI, so <code>GetMessage</code> becomes <code>GetMessageA</code> </p></li>\n<li><p>Windows.h was loaded with symbols set for Unicode, so <code>GetMessage</code> becomes <code>GetMessageW</code></p></li>\n</ol>\n\n<p>If you\'ve compiled two different files in ways that trigger two different scenarios, you\'ll get a linker error.  The error message indicates that the <code>Comms::Exception</code> class was an instance of #2, above -- perhaps it\'s used somewhere that windows.h hasn\'t been loaded?</p>\n\n<p>Other things I\'d do in your place, just as a matter of routine:</p>\n\n<p>1) Ensure that my include and library paths don\'t contain anything that I\'m not expecting.</p>\n\n<p>2) Do a "build clean" and then manually verify it, deleting any extra object files if necessary.</p>\n\n<p>3) Make sure there aren\'t any hardcoded paths in include statements that don\'t mean what they meant when the project was originally rebuilt.</p>\n\n<p>EDIT: Fighting with the formatting :(</p>\n'}, {'answer_id': 5940, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 0, 'selected': False, 'text': "<p>windows.h is declared at the top of IOCompletionPort.h as an include - I was sick of seeing 7 lines just to include 1 file so I have wrapped it its own file and includes that itself. This also contains some additional #defines (i.e. ULONG_PTR) as our main app won't compile with the Platform SDK installed:-(</p>\n<ol>\n<li>That is confirmed. Nothing is out of place.</li>\n<li>I've done that - deleted the build directories</li>\n<li>I never use hard-coded paths.</li>\n</ol>\n"}, {'answer_id': 5945, 'author': 'Josh', 'author_id': 257, 'author_profile': 'https://Stackoverflow.com/users/257', 'pm_score': 0, 'selected': False, 'text': "<p>Presuming you haven't futzed around with the Project settings deleting something you ought not have (which is where I'd expect external dependencies like User32.lib to be):</p>\n\n<p>Check Tools | Options | Directories | Libraries (going from memory here) and ensure that you're not missing the common-all-garden variety lib directories (again, without VC6 in front of me, I can't tell you what they are)</p>\n"}, {'answer_id': 6725, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 1, 'selected': False, 'text': '<p>@Curt: I think you came the closest. I haven\'t tested this but I think I sort of gave the answer in my original question.</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/ms644936.aspx" rel="nofollow noreferrer">GetMessage</a> is a define in Windows.h wrapped in a ifndef block to switch between Ansi (GetMessageA) and Unicode (GetMessageW).</p>\n'}, {'answer_id': 75673, 'author': 'Michael Burr', 'author_id': 12711, 'author_profile': 'https://Stackoverflow.com/users/12711', 'pm_score': 0, 'selected': False, 'text': "<p>This is a general problem with the way Microsoft handled the ANSI vs. Unicode APIs.  Since they are all (or pretty much all) done by defining macros for the function names that resolve to the 'A' or 'W' versions of the function names you cannot safely have an identifier in your namespace/class/struct/enum/function that matches a Windows API name.</p>\n\n<p>The windows.h macros run roughshod over all other namespaces.</p>\n"}]
['https://Stackoverflow.com/questions/5892', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/342/']