错误消息如下:
qt.network.ssl:QSslSocket:无法解析 TLSv1_1_client_method
qt.network.ssl:QSslSocket:无法解析 TLSv1_2_client_method
qt.network.ssl:QSslSocket:无法解析 TLSv1_1_server_method
qt.network.ssl:QSslSocket:无法解析 TLSv1_2_server_method
qt.network.ssl:QSslSocket:无法解析 SSL_select_next_proto
qt.network.ssl:QSslSocket:无法解析 SSL_CTX_set_next_proto_select_cb
qt.network.ssl:QSslSocket:无法解析 SSL_get0_next_proto_negotiated
qt.network.ssl:QSslSocket:无法解析 SSL_set_alpn_protos
qt.network.ssl:QSslSocket:无法解析 SSL_CTX_set_alpn_select_cb
qt.network.ssl:QSslSocket:无法解析 SSL_get0_alpn_selected
我运行 Windows 7 机器,在我的 D: 驱动器上安装了 openssl 1.1.0。我正在使用 Qt5.9.0
我的简历
QT += core network
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += main.cpp \
server.cpp \
commands.cpp \
packet.cpp
HEADERS += \
server.h \
commands.h \
packet.h
INCLUDEPATH += D:\OpenSSL-Win32\include\openssl
INCLUDEPATH += D:\OpenSSL-Win32\bin
LIBS += -L D:\OpenSSL-Win32\lib -llibcrypto
LIBS += -L D:\OpenSSL-Win32\lib -llibssl
这是触发错误的代码:
QString Commands::getPublicIp()
{
QString temp;
QNetworkAccessManager networkManager;
QUrl url("http://api.ipify.org");
QString query = "format=json";
url.setQuery(query);
QNetworkReply* reply = networkManager.get(QNetworkRequest(url));
QObject::connect(
reply
, &QNetworkReply::finished
, [&](){
if(reply->error() != QNetworkReply::NoError) {
return QString();
} else {
QJsonObject jsonObject= QJsonDocument::fromJson(reply->readAll()).object();
QHostAddress ip(jsonObject["ip"].toString());
temp = QString("002 " + ip.toString());
}
reply->deleteLater();
}
);
return temp;
}
我不断收到 qt.network.ssl 错误,在链接 openssl 后,我不断收到编译错误:
:-1: 错误: 找不到 D:\OpenSSL-Win32\lib: 权限被拒绝
:-1: 错误:找不到-llibssl
collect2.exe:-1: 错误: 错误: ld 返回 1 退出状态
尽管我目前没有使用 OpenSSL,但我愿意以后使用它。