1

i am trying to create an RPC server and client program. I am using this tutorial http://www.codeproject.com/Articles/4878/Introduction-to-RPC-Part-2

i copied the code exactly as it is in the website but i get this error when i try run it:

Error 1 error C2664: 'RpcServerUseProtseqEpW' : cannot convert parameter 1 from 'char *' to 'RPC_WSTR'

the problem is here:

  status = RpcServerUseProtseqEp(
  reinterpret_cast<unsigned char*>("ncacn_ip_tcp"), // Use TCP/IP protocol.
  RPC_C_PROTSEQ_MAX_REQS_DEFAULT, // Backlog queue length for TCP/IP.
  reinterpret_cast<unsigned char*>("4747"), // TCP/IP port to use.
  NULL); // No security.
Lisa Collins
  • 101
  • 3
  • 13
  • Your compiling with Unicode, use `(RPC_WSTR)L"ncacn_ip_tcp"`, etc. instead. – Jesse Good Apr 10 '13 at 08:57
  • Or [see this answer to turn off unicode](http://stackoverflow.com/questions/1319461/how-do-i-turn-off-unicode-in-a-vc-project). – Jesse Good Apr 10 '13 at 09:06
  • turning off unicode just causes more errors :error LNK2019: unresolved external symbol __imp__RpcServerListen@12 referenced in function _main rpcServer.obj – Lisa Collins Apr 10 '13 at 09:13
  • Those "more errors" are linker errors which happen after the compile stage. Turning off unicode fixed the error in your question. Now you have to link to the proper libs and include the proper headers. Add `Rpcrt4.lib` to your library directories or add `#pragma comment(lib, "Rpcrt4.lib")` to the top of your source file. – Jesse Good Apr 10 '13 at 10:28
  • @JesseGood adding that library didn't help – Lisa Collins Apr 11 '13 at 10:13
  • You probably didn't include `Rpc.h` either. This is pretty basic compiling and linking, you might want to learn about C++. – Jesse Good Apr 11 '13 at 21:03
  • no i did include rpc.h and rpcndr.h – Lisa Collins Apr 12 '13 at 08:42

0 Answers0