未解析的外部符号 __im__RpcServerListn
我已经包含了 Rpc.h,但仍然收到错误 LNK2019:函数 _main 中引用了无法解析的外部符号 __im__RpcServerListen@12。我还需要做些什么才能调用这个函数吗?
I already included Rpc.h
, but I am still receiving error LNK2019: unresolved external symbol __im__RpcServerListen@12 referenced in function _main
. Is there anything else I need to do to be able to call this function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
包含头文件是不够的,它只是告诉编译器您想要使用的类型、函数等。
您还必须链接相关的目标文件或库,因为它们包含您将调用的实际代码。您可以看出这一点,因为错误以
LNK
开头,这意味着您遇到了链接器问题,而不是编译器问题。应在链接阶段指定您需要链接到的实际文件。对于 Windows RPC,这似乎是
rpcrt4.lib
(请参阅 此处)。It's not enough to include the header file, that just tells the compiler about the types, functions and so on, that you want to use.
You also have to link with the relevant object files or libraries since they contain the actual code that you will be calling. You can tell this because the error starts with
LNK
, meaning you have a linker issue rather than a compiler one.The actual files that you need to link to should be specified for the linking phase. For Windows RPC, this appears to be
rpcrt4.lib
(see here).