我正在学习C Windows RPC编程。下面是我编写和编译的虚拟RPC服务器的源代码,没有错误:
#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);
}midl文件的编译也没有错误。MIDL编译产生了预期的md5_s.c和md5_c.c。如果需要,下面是md5.idl文件:
[
uuid(D86FBC01-D6A7-4941-9243-07A4EC65E8CB),
version(1.0),
]
interface md5
{
void md5([in, string] const char* szMsg);
};在链接阶段,会产生以下错误:
LNK2019: unresolved external symbol __imp__RpcServerListen referenced in function main对于每个特定于RPC的函数,例如RpcServerRegisterIf或RpcServerUseProtseqEp,我都有相同的错误。我正在使用2013。
我想这是因为漏掉了一个,但我不知道是哪一个。我试着加入rpc.h,没有任何改变。
我是否必须在我的项目中包括产生的md5_s.c?我没有解决任何问题就试过了。
谢谢你的帮助!
发布于 2015-05-04 13:10:54
您需要链接到Rpcrt4.lib。如果使用visual,请将其添加到Project -> Properties -> Configuration Properties -> Linker -> Input ->附加依赖项中。
https://stackoverflow.com/questions/30030793
复制相似问题