【发布时间】:2015-05-31 10:03:58
【问题描述】:
我正在尝试使用 OpenSSL 支持构建 Qt(版本 5.4.1)的静态构建。我是这样配置的:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl-linked -I C:\OpenSSL-Win32\include
-L C:\OpenSSL-Win32\lib\VC\static
-nomake examples -nomake tests
include 和 lib 目录有效。我在Qt5Network.lib 中收到大量链接错误。
Qt5Network.lib(qhttpnetworkconnectionchannel.obj) : error LNK2019: unresolved ex
ternal symbol "public: static class QSharedPointer<class QSslContext> __cdecl QS
slSocketPrivate::sslContext(class QSslSocket *)" (?sslContext@QSslSocketPrivate@
@SA?AV?$QSharedPointer@VQSslContext@@@@PAVQSslSocket@@@Z) referenced in function
"protected: void __thiscall QHttpNetworkConnectionChannel::_q_connected(void)"
(?_q_connected@QHttpNetworkConnectionChannel@@IAEXXZ)
Qt5Network.lib(qhttpprotocolhandler.obj) : error LNK2019: unresolved external sy
mbol "public: __int64 __thiscall QSslSocket::encryptedBytesToWrite(void)const "
(?encryptedBytesToWrite@QSslSocket@@QBE_JXZ) referenced in function "private: vi
rtual bool __thiscall QHttpProtocolHandler::sendRequest(void)" (?sendRequest@QHt
tpProtocolHandler@@EAE_NXZ)
C:\Qt\5.4\qtbase\bin\xmlpatterns.exe : fatal error LNK1120: 31 unresolved extern
als
jom: C:\Qt\5.4\qtxmlpatterns\tools\xmlpatterns\Makefile [release] Error 2
jom: C:\Qt\5.4\qtxmlpatterns\tools\Makefile [sub-xmlpatterns-make_first] Error 2
jom: C:\Qt\5.4\qtxmlpatterns\Makefile [sub-tools-make_first] Error 2
jom: C:\Qt\5.4\Makefile [module-qtxmlpatterns-make_first] Error 2
我之前能够在没有 OpenSSL 支持的情况下创建静态构建。错误消息还表明,该问题与 OpenSSL 有关。
有没有人想办法解决这个问题?
更新
这些配置产生相同的错误:
配置一:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl-linked -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32\lib\VC\static
OPENSSL_LIBS="-llibeay32MT -lssleay32MT" -nomake examples -nomake tests
配置2:
configure -opensource -release -c++11 -static -platform win32-msvc2013
-openssl -I C:\OpenSSL-Win32\include -L C:\OpenSSL-Win32
-nomake examples -nomake tests
更新 2
我也尝试过,所以按照qBittorrent wiki 中的精彩教程进行操作,得到了同样的错误。
如果这确实是一个 Qt 错误,正如弗兰克在 his comment 中所建议的那样,如果有人能推荐 Qt 的最后一个版本,这也将非常有用。
更新 3
在bugreports.qt.io 我收到了意见,这不是一个错误:
您实际上并没有告诉构建链接 openssl 库。 http://doc.qt.io/qt-5/ssl.html 给出了以下示例:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl 链接
您需要针对您的编译器和库位置进行调整 当然。
在参考文档页面上给出了这个例子:
OPENSSL_LIBS='-L/opt/ssl/lib -lssl -lcrypto' ./configure -openssl-linked
我在我编译的 OpenSSL 版本中找不到 ssl 或加密库,也没有在二进制分发中找到。我确实有标题。我只有 ssleay32 和 libeay32 库。
configure 命令确实提示将这些库设置为提到的变量:
NOTE: When linking against OpenSSL, you can override the default
library names through OPENSSL_LIBS
and optionally OPENSSL_LIBS_DEBUG/OPENSSL_LIBS_RELEASE
For example:
configure -openssl-linked OPENSSL_LIBS="-lssleay32 -llibeay32"
通过设置这个变量,我仍然会遇到同样的错误。
更新 5
不完全是我想要的,但向前迈进了一步:
我已经下载了最近(4 天前)发布的 Qt 5.4.2 的源代码,并且我能够使用动态链接的 OpenSSL(-openssl 开关)创建静态构建。
我仍在寻找静态链接 OpenSSL 的解决方案。我仍然有相同的链接错误。
【问题讨论】:
-
很可能是一个 Qt 错误,那么值得在 Qt JIRA 中报告它。当说“Qt 5.4”时,你是指 5.4.0 还是 5.4.1?
-
@FrankOsterfeld 谢谢,我已将其报告为错误。 bugreports.qt.io/browse/QTBUG-46405 我的意思是 5.4.1,不准确之处见谅。
-
@FrankOsterfeld 我得到的答案是这不是一个错误,但我个人还没有完全确定它。你能推荐一个 Qt 版本吗?
-
" 在我编译的 OpenSSL 构建中找不到 ssl 或加密库" 好吧,先解决这个问题,然后你的问题与 Qt 无关。
-
@KubaOber 说起来容易做起来难。我已经下载了 OpenSSL for Windows 的官方二进制发行版,它不包含它。我不知道我能做些什么。
标签: c++ qt deployment compilation static-linking