我如何使用带有 Visual Studio 的 vcpkg 静态 link 我的项目依赖项?
How can I statically link my project dependencies using vcpkg with Visual Studio?
我已经阅读了一些方法来做我想做的事,但 none 行之有效,他们最终使用了相同的方法。
我试过 this solution,但我无法让它工作...
这是我得到的输出:
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_accept
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_closesocket
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_recv
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_send
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_socket
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSACloseEvent
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSACloseEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSACreateEvent
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSACreateEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEnumNetworkEvents
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEnumNetworkEvents
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEventSelect
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEventSelect
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAResetEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAWaitForMultipleEvents
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(asyn-thread.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(sendf.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __WSAFDIsSet
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __imp_select
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_connect
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_connect
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getpeername
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_getpeername
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getsockopt
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(doh.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(socks_sspi.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(hostip.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(smb.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(socks_sspi.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(transfer.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>libcurl.lib(transfer.c.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>libcurl.lib(urlapi.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(hostip.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(system_win32.c.obj) : error LNK2001: unresolved external symbol __imp_WSAStartup
1>libcurl.lib(system_win32.c.obj) : error LNK2001: unresolved external symbol __imp_WSACleanup
1>libcurl.lib(rand.c.obj) : error LNK2001: unresolved external symbol __imp_ntohl
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertOpenStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertOpenStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertCloseStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertCloseStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertEnumCertificatesInStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertFindCertificateInStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateContext
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateContext
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CryptStringToBinaryA
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_PFXImportCertStore
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_listen
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_listen
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_recvfrom
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_sendto
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_getaddrinfo
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_freeaddrinfo
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_htonl
1>libcurl.lib(nonblock.c.obj) : error LNK2001: unresolved external symbol __imp_ioctlsocket
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CryptDecodeObjectEx
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertAddCertificateContextToStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFindExtension
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertGetNameStringA
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CryptQueryObject
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertCreateCertificateChainEngine
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateChainEngine
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertGetCertificateChain
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateChain
1>libcurl.lib(curl_gethostname.c.obj) : error LNK2001: unresolved external symbol __imp_gethostname
1>C:\Users\pedro\source\repos\vgm\x64\Release\vgm.exe : fatal error LNK1120: 53 unresolved externals
有什么解决办法吗?
我的全局变量部分 .vcxproject
:
我的Visual Studio的冗长级别(来自提到的解决方案):
vcpkg list
的输出:
使用的运行时库类型:
我找到了一种解决方案 (issue from vcpkg's github) 说我应该手动添加 Ws2_32.Lib
、Wldap32.Lib
和 Crypt32.Lib
但我不知道该怎么做那...
提前致谢!
您需要将配置属性->VC++目录下的lib目录设置为vcpkg静态lib目录。最重要的是,您需要 link 配置属性->链接器下的库或使用 pragma comment(lib,"libname")
我已经阅读了一些方法来做我想做的事,但 none 行之有效,他们最终使用了相同的方法。
我试过 this solution,但我无法让它工作...
这是我得到的输出:
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_accept
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_closesocket
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_recv
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_send
1>libcurl.lib(memdebug.c.obj) : error LNK2001: unresolved external symbol __imp_socket
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSACloseEvent
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSACloseEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSACreateEvent
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSACreateEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEnumNetworkEvents
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEnumNetworkEvents
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEventSelect
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAEventSelect
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAResetEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetEvent
1>libcurl.lib(multi.c.obj) : error LNK2001: unresolved external symbol __imp_WSAWaitForMultipleEvents
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(asyn-thread.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(sendf.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_WSAGetLastError
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __WSAFDIsSet
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __imp_select
1>libcurl.lib(select.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_WSASetLastError
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_bind
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_connect
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_connect
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getpeername
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_getpeername
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_getsockname
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_getsockopt
1>libcurl.lib(telnet.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(doh.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(socks_sspi.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(hostip.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(smb.c.obj) : error LNK2001: unresolved external symbol __imp_htons
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(socks_sspi.c.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(transfer.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_setsockopt
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>libcurl.lib(transfer.c.obj) : error LNK2001: unresolved external symbol __imp_WSAIoctl
1>libcurl.lib(urlapi.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(connect.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(hostip.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_inet_pton
1>libcurl.lib(system_win32.c.obj) : error LNK2001: unresolved external symbol __imp_WSAStartup
1>libcurl.lib(system_win32.c.obj) : error LNK2001: unresolved external symbol __imp_WSACleanup
1>libcurl.lib(rand.c.obj) : error LNK2001: unresolved external symbol __imp_ntohl
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertOpenStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertOpenStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertCloseStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertCloseStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertEnumCertificatesInStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertFindCertificateInStore
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateContext
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateContext
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_CryptStringToBinaryA
1>libcurl.lib(schannel.c.obj) : error LNK2001: unresolved external symbol __imp_PFXImportCertStore
1>libcurl.lib(ftp.c.obj) : error LNK2001: unresolved external symbol __imp_listen
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_listen
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_recvfrom
1>libcurl.lib(tftp.c.obj) : error LNK2001: unresolved external symbol __imp_sendto
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_getaddrinfo
1>libcurl.lib(curl_addrinfo.c.obj) : error LNK2001: unresolved external symbol __imp_freeaddrinfo
1>libcurl.lib(socketpair.c.obj) : error LNK2001: unresolved external symbol __imp_htonl
1>libcurl.lib(nonblock.c.obj) : error LNK2001: unresolved external symbol __imp_ioctlsocket
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CryptDecodeObjectEx
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertAddCertificateContextToStore
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFindExtension
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertGetNameStringA
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CryptQueryObject
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertCreateCertificateChainEngine
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateChainEngine
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertGetCertificateChain
1>libcurl.lib(schannel_verify.c.obj) : error LNK2001: unresolved external symbol __imp_CertFreeCertificateChain
1>libcurl.lib(curl_gethostname.c.obj) : error LNK2001: unresolved external symbol __imp_gethostname
1>C:\Users\pedro\source\repos\vgm\x64\Release\vgm.exe : fatal error LNK1120: 53 unresolved externals
有什么解决办法吗?
我的全局变量部分 .vcxproject
:
我的Visual Studio的冗长级别(来自提到的解决方案):
vcpkg list
的输出:
使用的运行时库类型:
我找到了一种解决方案 (issue from vcpkg's github) 说我应该手动添加 Ws2_32.Lib
、Wldap32.Lib
和 Crypt32.Lib
但我不知道该怎么做那...
提前致谢!
您需要将配置属性->VC++目录下的lib目录设置为vcpkg静态lib目录。最重要的是,您需要 link 配置属性->链接器下的库或使用 pragma comment(lib,"libname")