title: MSVC unresolved external symbol linking executables
body: <p>I have two existing executables A and T, in the same solution that both ran just fine before I touched them.  In executable A is a header defining a class P, and a prototype for a static instance MyP.  The definitions are compiled in project A.  In executable T, I wanted to call member functions of MyP in project A, so I added dllimport/export macros to the declarations of the class and MyP in the headers (not at the definitions), and included the headers in project T.  The dllimport/export macros are standard, and A_EXPORTS is defined in project A, but not in T.</p>
  
  <pre><code>#ifdef A_EXPORTS
  #define A_API __declspec(dllexport)
  #else
  #define A_API __declspec(dllimport)
  #endif
  
  //various definitions and includes, defining ENUM_RECORDING_TYPE and ERROR
  A_API HFILE viosopen(const _TCHAR *path, ENUM_RECORDING_TYPE rt, int flags);
  A_API struct P { 
      ERROR B(SHORT phraseNum);
  };
  A_API extern P MyP;
  </code></pre>
  
  <p>I added project A as a dependency on project T in the solution.  A still compiles fine, but T comes up with <code>unresolved external symbol "__declspec(import) &lt;snip&gt; referenced in function &lt;snip&gt;</code> for the function calls, and <code>unresolved external symbol "__declspec(dllimport) class P MyP" &lt;snip&gt;</code> for the static object.  I also see in the output log, right after it starts linking: <code>Creating library Debug/A.lib and object Debug/A.exp</code> which seems ominous since it's supposed to be linking against the existing executable.</p>
  
  <p>My question is: how can I tell MSVC 2010 where those are?  I thought simply setting A as a dependency would have it figure that out automatically.  I can link against the existing executable, right?</p>