Reputation: 3189
I am learning C Windows RPC programming. Here is the source code for a dummy RPC Server I wrote and compiled without errors:
#include <stdio.h>
#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);
}
The midl files get compiled without errors as well. The MIDL-compilation produces md5_s.c
and md5_c.c
as expected. Here is md5.idl
file if needed:
[
uuid(D86FBC01-D6A7-4941-9243-07A4EC65E8CB),
version(1.0),
]
interface md5
{
void md5([in, string] const char* szMsg);
};
During the Linkage stage the following errors are produced:
LNK2019: unresolved external symbol __imp__RpcServerListen referenced in function main
I have same errors for every RPC-specific functions, such as RpcServerRegisterIf
or RpcServerUseProtseqEp
. I am using Microsoft Visual Studio 2013.
I think this comes from a missing include; but I can't figure which one. I tried to include rpc.h
, without any change.
Do I have to include in my project the produced md5_s.c
? I have tried so without resolving anything.
Thanks for helping!
Upvotes: 1
Views: 2038
Reputation: 1925
You need to link against Rpcrt4.lib. If you are using visual studio, add it in the Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies.
Upvotes: 5