Visual Studio 2015 Community ZeroMQ静态库链接错误
Visual Studio 2015 Community ZeroMQ static library linking error
我正试图在Visual Studio 2015中使用ZeroMQ的静态库。我通过克隆git存储库,将fd.hpp中的windows.hpp include从#include <windows.hpp>
更改为#include "windows.hpp"
,将libsodium放在正确的位置,然后批量构建vs2015解决方案中的所有内容来生成它。
在我尝试在中使用ZeroMQ的程序中,我包括ZeroMQ包含目录,包括ZeroMQ发布静态目录(libzmq\bin\W32\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:Programmingc++HttpServerReleaseHttpServer.exe : fatal error LNK1120: 35 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
让我困惑的是,当我包含ZeroMQ发布动态目录(libzmq\bin\W32\release \v140\dynamic)时,它编译得很好。但是,当我尝试运行我的程序时,它需要运行dll。这是我试图通过使用ZeroMQ的静态库来避免的。我不知道现在该怎么办。
编辑
我不相信我的问题与此有关,因为在我看来,static.lib引用了.dll中的内容,这意味着我需要将.dll包含在我的程序中,这不是意味着我没有真正静态地链接库吗?有人能够在不需要dll的情况下在windows上使用ZeroMQ吗?
看起来我也需要链接到这些库。
wsock32.lib
ws2_32.lib
Iphlpapi.lib
对于任何发现并正在阅读这篇文章的人来说,LetoTheSecond的回答都是正确的。
如果你像我一样是VS的新手,这里有关于该做什么的明确说明。
右键单击您的项目
转到链接器->输入
将以下内容添加到"附加依赖项">
ws2_32.lib;wsock32.lib;Iphlpapi.lib
(为VS2017工作)
- 静态数据成员的问题-修复链接错误会导致编译器错误
- Visual Studio mkl_link_tool.exe链接错误
- C++ 实现模板单例类时出现链接错误
- 使用类模板的方法链接错误
- MySQL C++连接器链接错误
- VS 2015 链接错误 无法构建依赖于 libcurl 的项目
- 运行 C++ 单元测试时LNK2005链接错误
- 对 CMake 中'cudaRegisterLinkedBinary'链接错误的未定义引用?
- 链接错误,包括我创建的相同头文件 - C++
- 在Embarcadero C++ Builder中生成的DLL未解决的外部链接错误
- 使用标头保护的多个定义链接错误
- 链接错误:未定义对 stdscr 和 wgetch 的引用
- 使用 Vivek 的 Vcam / 捕获源过滤器构建/链接错误
- 升压program_options中的链接错误
- 使用 g++ 预处理器进行替换会导致链接错误
- 在调试配置中编译工作正常,但发布会给出链接错误
- 相邻矩阵设置链接错误
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++链接错误,我理解但无法解决
- 是什么导致macOS Mojave上的GoogleTest链接错误