Tho*_*mas 5 c++ protocol-buffers grpc visual-studio-2017
Win10,Visual Studio 15 2017
这就是我到目前为止所做的:
cmake --build 在 grpc 上之后我的空项目,包括编译没有错误的 pb 文件。
然后我写了一些代码来使用和测试 grpc,但是当我这次尝试编译时,我收到了几个错误,比如
LNK2019 unresolved external symbol _address_sorting_init referenced in function "void __cdecl grpc_resolver_dns_ares_init(void)" (?grpc_resolver_dns_ares_init@@YAXXZ) grpc.lib(dns_resolver_ares.obj)
LNK2001 unresolved external symbol __imp__htons@4 grpc.lib(socket_utils_windows.obj)
LNK2019 unresolved external symbol _ares_gethostbyname referenced in function "struct grpc_ares_request * __cdecl grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked(char const *,char const *,char const *,struct grpc_pollset_set *,struct grpc_closure *,struct grpc_lb_addresses * *,bool,char * *,struct grpc_combiner *)" (?grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked@@YAPAUgrpc_ares_request@@PBD00PAUgrpc_pollset_set@@PAUgrpc_closure@@PAPAUgrpc_lb_addresses@@_NPAPADPAUgrpc_combiner@@@Z) grpc.lib(grpc_ares_wrapper.obj)
Run Code Online (Sandbox Code Playgroud)
The first symbol "address_sorting_init" comes from the library address sorting present at https://github.com/grpc/grpc/tree/master/third_party/address_sorting
The second symbol is from the windows API library "ws2_32", the winsock library from Microsoft.
The third symbol is from the c-ares library: https://c-ares.haxx.se/
所有 3 个库都是在 Windows 下构建 grpc 所必需的,因此您应该将它们添加到您的项目中。