简体   繁体   中英

Visual Studio 2015 Community ZeroMQ static library linking error

I am attempting to use the static library of ZeroMQ in Visual Studio 2015. I generated it by cloning the git repository , changing the windows.hpp include in fd.hpp from #include <windows.hpp> to #include "windows.hpp" , putting libsodium in the right place, and then batch building everything in the vs2015 solution.

In the program I am trying to use ZeroMQ in I included the ZeroMQ include directory, included the ZeroMQ release static directory (libzmq\\bin\\Win32\\Release\\v140\\static), added libzqm.lib as an additional dependency, defined ZMQ_STATIC and _CRT_SECURE_NO_WARNINGS for some other things I am doing in my program, and changed the runtime library to Multi-threaded /MT.

When I try to compile at this point I get these errors:

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 ==========

What confuses me is that when I include the ZeroMQ release dynamic directory (libzmq\\bin\\Win32\\Release\\v140\\dynamic), which contains the dll, it compiles just fine. However, when I try to run my program it requires the dll to run. This is what I am trying to avoid by using the static library of ZeroMQ. I'm at a loss as to what to do now.

EDIT

I do not believe my question is related to this because it appears to me that the static .lib is referencing stuff in the .dll which means that I need to include the .dll with my program, doesn't this mean I am not really statically linking the library? Has anyone been able to use ZeroMQ on windows without needing a dll?

Looks like I needed to link to these libraries as well.

wsock32.lib
ws2_32.lib
Iphlpapi.lib

For anyone who finds this and is reading this, LetoTheSecond's response is correct.

If you are a novice with VS like myself here are explicit instructions as to what to do.

Right click on your project.
Go to Linker -> Input
Add the following to "Additional Dependencies"

ws2_32.lib;wsock32.lib;Iphlpapi.lib

(Worked for VS2017)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM