[英]poco library, static linking (MT)
我需要在多线程(运行时)中编译我的程序,并且我已经使用 vcpkg 为静态模式和 dll 安装了 poco 库,并且我已经添加了:
<PropertyGroup Label="Globals">
...
<VcpkgTriplet Condition="'$(Platform)'=='Win32'">x86-windows-static</VcpkgTriplet>
<VcpkgTriplet Condition="'$(Platform)'=='x64'">x64-windows-static</VcpkgTriplet>
</PropertyGroup>
我的项目在mt模式下编译,在mt dll中编译没有问题,但是当我想在mt模式下编译时,出现以下错误:
1>PocoNetmt.lib(Net.obj) : error LNK2001: unresolved external symbol __imp_WSAStartup
1>libcrypto.lib(b_sock.obj) : error LNK2001: unresolved external symbol __imp_WSAStartup
1>PocoNetmt.lib(Net.obj) : error LNK2001: unresolved external symbol __imp_WSACleanup
1>libcrypto.lib(b_sock.obj) : error LNK2001: unresolved external symbol __imp_WSACleanup
1>PocoNetmt.lib(SocketAddress.obj) : error LNK2001: unresolved external symbol __imp_htons
1>PocoNetmt.lib(SocketAddress.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>PocoNetmt.lib(SocketAddressImpl.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcrypto.lib(b_sock.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>libcrypto.lib(b_addr.obj) : error LNK2001: unresolved external symbol __imp_ntohs
1>PocoNetmt.lib(SocketAddress.obj) : error LNK2001: unresolved external symbol __imp_getservbyname
1>PocoNetmt.lib(DNS.obj) : error LNK2001: unresolved external symbol __imp_gethostname
...
问题似乎是网络标题和我的标题:
#include "Poco/Net/MailMessage.h"
#include "Poco/Net/MailRecipient.h"
#include "Poco/Net/SMTPClientSession.h"
#include "Poco/Net/NetException.h"
#include "Poco/Net/SecureSMTPClientSession.h"
#include "Poco/Net/InvalidCertificateHandler.h"
#include "Poco/Net/AcceptCertificateHandler.h"
#include "Poco/Net/SSLManager.h"
#include "Poco/Net/SecureStreamSocket.h"
#include "Poco/Net/MailRecipient.h"
我还尝试将 ws2_32.lib 和 iphlpapi.lib 添加到其他依赖项,但我有新的错误,例如未解析的外部符号...,为什么会发生这种情况?
我终于想通了,如何解决这个问题,3天后,我们需要将 crypt32.lib 和 ws2_32.lib 添加到链接器/附加依赖项。 我希望这可以帮助处于类似情况的人:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.