Visual Studio 2015社区ZeroMQ静态库链接错误

Let*_*ond 1 c++ static-libraries zeromq static-linking visual-studio-2015

我试图在Visual Studio 2015中使用ZeroMQ的静态库.我通过克隆git存储库生成它,将fd.hpp中的windows.hpp include更改#include <windows.hpp>#include "windows.hpp",将libsodium放在正确的位置,然后批量构建所有内容vs2015解决方案.

在程序中我试图使用ZeroMQ,我包括ZeroMQ包含目录,包括ZeroMQ发布静态目录(libzmq\bin\Win32\Release\v140\static),添加了libzqm.lib作为附加依赖项,定义了ZMQ_STATIC和_CRT_SECURE_NO_WARNINGS对于我在程序中执行的其他一些操作,并将运行时库更改为多线程/ MT.

当我在这一点上尝试编译时,我得到以下错误:

1>------ Build started: Project: HttpServer, Configuration: Release Win32 ------
1>  main.cpp
1>libzmq.lib(zmq.obj) : error LNK2001: unresolved external symbol ___WSAFDIsSet@8
1>libzmq.lib(socket_poller.obj) : error LNK2001: unresolved external symbol ___WSAFDIsSet@8
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol ___WSAFDIsSet@8
1>libzmq.lib(zmq.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>libzmq.lib(socket_poller.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__select@20
1>libzmq.lib(zmq.obj) : error LNK2001: unresolved external symbol __imp__WSAStartup@8
1>libzmq.lib(zmq.obj) : error LNK2001: unresolved external symbol __imp__WSACleanup@0
1>libzmq.lib(socks_connecter.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(tcp.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(tcp_connecter.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(zmq.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(err.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(socket_poller.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__htonl@4
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>libzmq.lib(udp_address.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>libzmq.lib(stream_engine.obj) : error LNK2001: unresolved external symbol __imp__htons@4
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>libzmq.lib(stream_engine.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol _if_nametoindex@4
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__getaddrinfo@16
1>libzmq.lib(socks.obj) : error LNK2001: unresolved external symbol __imp__getaddrinfo@16
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4
1>libzmq.lib(socks.obj) : error LNK2001: unresolved external symbol __imp__freeaddrinfo@4
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol __imp__getnameinfo@28
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__getnameinfo@28
1>libzmq.lib(tcp_address.obj) : error LNK2001: unresolved external symbol _in6addr_any
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__getsockopt@20
1>libzmq.lib(tcp_connecter.obj) : error LNK2001: unresolved external symbol __imp__getsockopt@20
1>libzmq.lib(socks_connecter.obj) : error LNK2001: unresolved external symbol __imp__getsockopt@20
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSACloseEvent@4
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSACreateEvent@0
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSAEventSelect@12
1>libzmq.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSAWaitForMultipleEvents@20
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__accept@12
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__accept@12
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>libzmq.lib(tcp_connecter.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>libzmq.lib(socks_connecter.obj) : error LNK2001: unresolved external symbol __imp__bind@12
1>libzmq.lib(socks_connecter.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(stream_engine.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(tcp_connecter.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>libzmq.lib(tcp_connecter.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>libzmq.lib(socks_connecter.obj) : error LNK2001: unresolved external symbol __imp__connect@12
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__listen@8
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__listen@8
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__recv@16
1>libzmq.lib(tcp.obj) : error LNK2001: unresolved external symbol __imp__recv@16
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__send@16
1>libzmq.lib(tcp.obj) : error LNK2001: unresolved external symbol __imp__send@16
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>libzmq.lib(signaler.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>libzmq.lib(tcp_listener.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>libzmq.lib(tcp.obj) : error LNK2001: unresolved external symbol __imp__setsockopt@20
1>libzmq.lib(udp_address.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__inet_addr@4
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__ioctlsocket@12
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__getpeername@12
1>libzmq.lib(ip.obj) : error LNK2001: unresolved external symbol __imp__socket@12
1>libzmq.lib(tcp.obj) : error LNK2001: unresolved external symbol __imp__WSAIoctl@36
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__inet_ntoa@4
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__recvfrom@24
1>libzmq.lib(udp_engine.obj) : error LNK2001: unresolved external symbol __imp__sendto@24
1>H:\Programming\c++\HttpServer\Release\HttpServer.exe : fatal error LNK1120: 35 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Run Code Online (Sandbox Code Playgroud)

令我困惑的是,当我包含ZeroMQ发布动态目录(libzmq\bin\Win32\Release\v140\dynamic),其中包含dll时,它编译得很好.但是,当我尝试运行我的程序时,它需要运行dll.这是我试图通过使用ZeroMQ的静态库来避免的.我现在不知道该做什么.

编辑

我不相信我的问题与有关,因为在我看来静态.lib是在.dll中引用的东西,这意味着我需要在我的程序中包含.dll,这不是说我不是真的静态链接图书馆?有没有人能够在Windows上使用ZeroMQ而不需要dll?

Let*_*ond 7

看起来我也需要链接到这些库.

wsock32.lib
ws2_32.lib
Iphlpapi.lib
Run Code Online (Sandbox Code Playgroud)