title: Windows RPC programming error: LNK 2019 unresolved external symbol RPCServerListen
body: <p>I am learning C Windows RPC programming. Here is the source code for a dummy RPC Server I wrote and compiled without errors:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "md5_h.h"
  #include "rpc.h"
  #include "rpcndr.h"
  
  int main() {
    RPC_STATUS status;
  
    status = RpcServerUseProtseqEp(
      (RPC_WSTR)("ncacn_ip_tcp"),
      RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
      (RPC_WSTR)("9191"),
      NULL);
  if (status) { exit(status); }
  
  status = RpcServerRegisterIf(
      md5_v1_0_c_ifspec,
      NULL,
      NULL);
  if (status) { exit(status); }
  
  status = RpcServerListen(
      1,
      RPC_C_LISTEN_MAX_CALLS_DEFAULT,
      FALSE);
  if (status) { exit(status); }
  
  return 0;
  }
  
  void __RPC_USER midl_user_free(void* p) {
    free(p);
  }
  
  void md5(const unsigned char* szMsg) {
    printf("voila %s\n", szMsg);
  }
  </code></pre>
  
  <p>The midl files get compiled without errors as well. The MIDL-compilation produces <code>md5_s.c</code> and <code>md5_c.c</code> as expected. Here is <code>md5.idl</code> file if needed:</p>
  
  <pre><code>[
  uuid(D86FBC01-D6A7-4941-9243-07A4EC65E8CB),
      version(1.0),
  ]
  interface md5
  {
    void md5([in, string] const char* szMsg);
  };
  </code></pre>
  
  <p>During the Linkage stage the following errors are produced:</p>
  
  <pre><code>LNK2019: unresolved external symbol __imp__RpcServerListen referenced in function main
  </code></pre>
  
  <p>I have same errors for every RPC-specific functions, such as <code>RpcServerRegisterIf</code> or <code>RpcServerUseProtseqEp</code>.  I am using Microsoft Visual Studio 2013.</p>
  
  <p>I think this comes from a missing include; but I can't figure which one. I tried to include <code>rpc.h</code>, without any change.</p>
  
  <p>Do I have to include in my project the produced <code>md5_s.c</code>? I have tried so without resolving anything.</p>
  
  <p>Thanks for helping!</p>