我按照https://stackoverflow.com/a/67875527/433718建议跑了
因此,这些软件包现在安装在我的计算机上:
vcpkg list
abseil:x64-windows 2021-03-24#1 an open-source collection designed to augment th...
c-ares:x64-windows 1.17.1#2 A C library for asynchronous DNS requests
grpc:x64-windows 1.37.0#3 An RPC library and framework
grpc[codegen]:x64-windows Build code generator machinery
openssl:x64-windows 1.1.1k#8 OpenSSL is an open source project that provides ...
protobuf:x64-windows 3.15.8#4 Protocol Buffers - Google's data interchange format
protobuf:x86-windows 3.15.8#4 Protocol Buffers - Google's data interchange format
protobuf[zlib]:x64-windows ZLib based features like Gzip streams
protobuf[zlib]:x86-windows ZLib based features like Gzip streams
re2:x64-windows 2020-10-01 RE2 is a fast, safe, thread-friendly alternative...
upb:x64-windows 2020-12-19#1 μpb (often written 'upb') is a small protobuf i...
zlib:x64-windows 1.2.11#11 A compression library
zlib:x86-windows 1.2.11#11 A compression library
这是我的代码:
#include <grpcpp/grpcpp.h>
using grpc::ServerBuilder;
int main(int argc, char** argv) {
ServerBuilder builder;
return 0;
}
在使用vcpkg时,我没有在属性中配置任何路径(例如其他依赖项)(我想这就是使用vcpkg的意义所在)。以下是vcpkg的配置页面:
我的项目没有在Visul Studio 2019中生成,因为有27个未解析的外部。。。
1>grpc.lib(iomgr_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSAStartup referenced in function "void __cdecl winsock_init(void)" (?winsock_init@@YAXXZ)
1>grpc.lib(iomgr_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSACleanup referenced in function "void __cdecl winsock_shutdown(void)" (?winsock_shutdown@@YAXXZ)
1>grpc.lib(socket_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_bind referenced in function "void __cdecl probe_ipv6_once(void)" (?probe_ipv6_once@@YAXXZ)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_bind
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_bind
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_bind
1>grpc.lib(socket_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_closesocket referenced in function "void __cdecl grpc_winsocket_shutdown(struct grpc_winsocket *)" (?grpc_winsocket_shutdown@@YAXPEAUgrpc_winsocket@@@Z)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_closesocket
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_closesocket
1>address_sorting.lib(address_sorting_windows.c.obj) : error LNK2001: unresolved external symbol __imp_closesocket
1>grpc.lib(socket_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_socket referenced in function "void __cdecl probe_ipv6_once(void)" (?probe_ipv6_once@@YAXXZ)
1>address_sorting.lib(address_sorting_windows.c.obj) : error LNK2001: unresolved external symbol __imp_socket
1>grpc.lib(resolve_address_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(tcp_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(socket_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(iocp_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>grpc.lib(socket_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>grpc.lib(tcp_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>grpc.lib(socket_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSASocketA referenced in function "void __cdecl grpc_wsa_socket_flags_init(void)" (?grpc_wsa_socket_flags_init@@YAXXZ)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSASocketA
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSASocketA
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSASocketA
1>grpc.lib(iocp_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSAGetOverlappedResult referenced in function "enum grpc_iocp_work_status __cdecl grpc_iocp_work(__int64)" (?grpc_iocp_work@@YA?AW4grpc_iocp_work_status@@_J@Z)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetOverlappedResult
1>grpc.lib(tcp_client_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetOverlappedResult
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSAGetOverlappedResult
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_getpeername referenced in function "void __cdecl on_accept(void *,struct grpc_error *)" (?on_accept@@YAXPEAXPEAUgrpc_error@@@Z)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_getsockname referenced in function "struct grpc_error * __cdecl prepare_socket(unsigned __int64,struct grpc_resolved_address const *,int *)" (?prepare_socket@@YAPEAUgrpc_error@@_KPEBUgrpc_resolved_address@@PEAH@Z)
1>grpc.lib(tcp_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>address_sorting.lib(address_sorting_windows.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_listen referenced in function "struct grpc_error * __cdecl prepare_socket(unsigned __int64,struct grpc_resolved_address const *,int *)" (?prepare_socket@@YAPEAUgrpc_error@@_KPEBUgrpc_resolved_address@@PEAH@Z)
1>grpc.lib(tcp_server_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_setsockopt referenced in function "void __cdecl on_accept(void *,struct grpc_error *)" (?on_accept@@YAXPEAXPEAUgrpc_error@@@Z)
1>grpc.lib(tcp_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>grpc.lib(resolve_address_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_getaddrinfo referenced in function "struct grpc_error * __cdecl windows_blocking_resolve_address(char const *,char const *,struct grpc_resolved_addresses * *)" (?windows_blocking_resolve_address@@YAPEAUgrpc_error@@PEBD0PEAPEAUgrpc_resolved_addresses@@@Z)
1>grpc.lib(resolve_address_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_freeaddrinfo referenced in function "struct grpc_error * __cdecl windows_blocking_resolve_address(char const *,char const *,struct grpc_resolved_addresses * *)" (?windows_blocking_resolve_address@@YAPEAUgrpc_error@@PEBD0PEAPEAUgrpc_resolved_addresses@@@Z)
1>grpc.lib(tcp_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSARecv referenced in function "void __cdecl on_read(void *,struct grpc_error *)" (?on_read@@YAXPEAXPEAUgrpc_error@@@Z)
1>grpc.lib(tcp_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSASend referenced in function "void __cdecl on_write(void *,struct grpc_error *)" (?on_write@@YAXPEAXPEAUgrpc_error@@@Z)
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2001: unresolved external symbol __imp_WSASend
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_htonl referenced in function "unsigned int __cdecl grpc_htonl(unsigned int)" (?grpc_htonl@@YAII@Z)
1>address_sorting.lib(address_sorting.c.obj) : error LNK2001: unresolved external symbol __imp_htonl
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_htons referenced in function "unsigned short __cdecl grpc_htons(unsigned short)" (?grpc_htons@@YAGG@Z)
1>grpc.lib(grpc_ares_wrapper.cc.obj) : error LNK2001: unresolved external symbol __imp_htons
1>grpc.lib(parse_address.cc.obj) : error LNK2001: unresolved external symbol __imp_htons
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_ntohl referenced in function "unsigned int __cdecl grpc_ntohl(unsigned int)" (?grpc_ntohl@@YAII@Z)
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_ntohs referenced in function "unsigned short __cdecl grpc_ntohs(unsigned short)" (?grpc_ntohs@@YAGG@Z)
1>grpc.lib(grpc_ares_wrapper.cc.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_inet_pton referenced in function "int __cdecl grpc_inet_pton(int,char const *,void *)" (?grpc_inet_pton@@YAHHPEBDPEAX@Z)
1>grpc.lib(socket_utils_windows.cc.obj) : error LNK2019: unresolved external symbol inet_ntop referenced in function "char const * __cdecl grpc_inet_ntop(int,void const *,char *,unsigned __int64)" (?grpc_inet_ntop@@YAPEBDHPEBXPEAD_K@Z)
1>grpc.lib(ssl_transport_security.cc.obj) : error LNK2001: unresolved external symbol inet_ntop
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSASetLastError referenced in function "public: __cdecl grpc_core::WSAErrorContext::~WSAErrorContext(void)" (??1WSAErrorContext@grpc_core@@QEAA@XZ)
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSAConnect referenced in function "public: int __cdecl grpc_core::GrpcPolledFdWindows::ConnectUDP(class grpc_core::WSAErrorContext *,struct sockaddr const *,int)" (?ConnectUDP@GrpcPolledFdWindows@grpc_core@@QEAAHPEAVWSAErrorContext@2@PEBUsockaddr@@H@Z)
1>grpc.lib(grpc_ares_ev_driver_windows.cc.obj) : error LNK2019: unresolved external symbol __imp_WSARecvFrom referenced in function "public: void __cdecl grpc_core::GrpcPolledFdWindows::ContinueRegisterForOnReadableLocked(void)" (?ContinueRegisterForOnReadableLocked@GrpcPolledFdWindows@grpc_core@@QEAAXXZ)
1>address_sorting.lib(address_sorting_windows.c.obj) : error LNK2019: unresolved external symbol __imp_connect referenced in function address_sorting_create_source_addr_factory_for_current_platform
我构建了Debug和x64配置。
我错过了什么?我想vcpkg会让生活更轻松吗?
这似乎是grpc包的问题。
在Windows for VisualC上链接gRPC的公认答案的第二部分准确地解决了我的问题。
我在cpp文件中添加了pragma注释(lib,“Ws2\u 32.lib”),问题就解决了。
它也可以这样修复(我从未解析的外部符号LNK2019截图):
Markdown 支持以比较简短的自动链接形式来处理网址和电子邮件信箱,只要是用方括号包起来, Markdown 就会自动把它转成链接。一般网址的链接文字就和链接地址一样,例如: <http://example.com/> Markdown 会转为: <a href="http://example.com/">http://example.com/</a> 邮址的自动链接也很类似,只是 Markd
我认为我的模板使用不当,但我不知道我做错了什么。这就像模板链表无法确定它需要使用我的术语类一样。 名单- 以下是Visual Studio 2012的确切错误: > 错误LNK1120:1未解决的外部C:\用户\迈克尔\文档\魔术公文包\尚普兰\课程工作\数据结构\pa2\调试\pa2.exe 标题。H 功能。cpp 链接列表。H 术语h
在写 linux-insides 一书的过程中,我收到了很多邮件询问关于链接器和链接器脚本的问题。所以我决定写这篇文章来介绍链接器和目标文件的链接方面的知识。 如果我们打开维基百科的 链接器 页,我们将会看到如下定义: 在计算机科学中,链接器(英文:Linker),是一个计算机程序,它将一个或多个由编译器生成的目标文件链接为一个单独的可执行文件,库文件或者另外一个目标文件 如果你曾经用 C 写过至
介绍 在写 linux-insides 一书的过程中,我收到了很多邮件询问关于链接器和链接器脚本的问题。所以我决定写这篇文章来介绍链接器和目标文件的链接方面的知识。 如果我们打开维基百科的 链接器 页,我们将会看到如下定义: 在计算机科学中,链接器(英文:Linker),是一个计算机程序,它将一个或多个由编译器生成的目标文件链接为一个单独的可执行文件,库文件或者另外一个目标文件 如果你曾经用 C
我不确定我是否正确理解http-keep-alive,在我看来,它应该重用tcp连接,而不是构建一个新的连接。然而,我发现了一些非常奇怪的事情,似乎很难预料http keep-alive的行为。 服务器:NodeJS&Express^4.16.3,我使用Wireshark分析结果 情况1: null 客户端 null 情况2: null 结果:建立了另外5个tcp连接(在图片中只有4个,因为屏幕截
我正试图通过浏览器链接启动我的android应用程序。 当我通过chrome浏览器打开链接时,它成功地显示了应用程序对话框选择器,它显示了像这样的方案可用的应用程序。 应用程序对话框选择器 但是当链接通过Chrome自定义选项卡打开时,它只是重定向到网站,而不显示应用对话框选择器。 我需要它来启动应用程序或显示对话框选择器,当链接从另一个应用程序(如gmail)打开时,它会打开应用程序内浏览器,而