title: How to compile a C++/CLI program into .lib and link it with a pure unmanaged C++ program?
body: <p>I'm following this <a href="http://www.codeproject.com/Articles/10020/Using-managed-code-in-an-unmanaged-application" rel="nofollow">http://www.codeproject.com/Articles/10020/Using-managed-code-in-an-unmanaged-application</a></p>
  
  <p>The example consist of 3 binaries:  </p>
  
  <ol>
  <li>C# code</li>
  <li>C++/CLI code</li>
  <li>C++ code</li>
  </ol>
  
  <p>The C++ code calls on the C++/CLI code, which then calls on the C# code, to achieve a way of running C# codes from C++.</p>
  
  <p>The problem is, the C++/CLI is compiled as a .dll, when I tried to compile it into .lib, so that the C++ code and be linked together with the C++/CLI code, it fails.</p>
  
  <p>So that the end result will only consist of 2 binaries.</p>
  
  <ol>
  <li>C# code</li>
  <li>C++ --LINK-- C++/CLI code</li>
  </ol>
  
  <p>The error</p>
  
  <pre><code>Error   1   error LNK2019: unresolved external symbol "__declspec(dllimport) public: static void __cdecl IMessageBoxWrapper::Destroy(class IMessageBoxWrapper *)" (__imp_?Destroy@IMessageBoxWrapper@@SAXPAV1@@Z) referenced in function _main  C:\Users\Zero\Desktop\UmanagedApp\UmanagedApp\main.obj  UmanagedApp
  
  Error   2   error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class IMessageBoxWrapper * __cdecl IMessageBoxWrapper::CreateInstance(void)" (__imp_?CreateInstance@IMessageBoxWrapper@@SAPAV1@XZ) referenced in function _main C:\Users\Zero\Desktop\UmanagedApp\UmanagedApp\main.obj  UmanagedApp
  </code></pre>