Getting "qt.network.ssl: QSslSocket: cannot call unresolved function..." when trying to send network request
-
What I'm trying to do is to send a simple request to a URL using Qt, however when I try to run the program I get these errors in the console: (The program doesn't crash, it only logs this in the console)
qt.network.ssl: QSslSocket: cannot call unresolved function SSLv23_client_method qt.network.ssl: QSslSocket: cannot call unresolved function SSL_CTX_new qt.network.ssl: QSslSocket: cannot call unresolved function SSL_library_init qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error qt.network.ssl: QSslSocket: cannot call unresolved function ERR_get_error
I browsed around for solutions for a while and managed to find several ones :
- Add "QT += network" in the pro file. (Didn't work)
- Add libeay32.dll and ssleay32.dll to the project .exe file. (Didn't work)
- Add libeay32.dll and ssleay32.dll to System32 folder. (Didn't work)
- Add libeay32.dll and ssleay32.dll to "D:\Qt\Tools\mingw530_32\bin" folder. (Didn't work)
Here's the networking part of my code:
QString requestUrl = "https://api.darksky.net/forecast/[key]/[latitude],[longitude]"; requestUrl = requestUrl.replace("[key]", key); requestUrl = requestUrl.replace("[latitude]", latitude); requestUrl = requestUrl.replace("[longitude]", longitude); qDebug() << "Request URL: " << requestUrl; QNetworkRequest request = QNetworkRequest(QUrl(requestUrl)); m_callback = callback; m_netMgr->connect(m_netMgr, &QNetworkAccessManager::finished, DarkSkyAPI::m_callback); m_netMgr->get(request);
And here's the function which is assigned to the DarkSkyAPI::m_callback function pointer variable:
void MainWindow::DarkSkyCallback(QNetworkReply *reply) { qDebug() << "Content:"; qDebug() << reply->readAll(); }
Not sure what I'm doing wrong here :/
-
@TheMushroom
Either your application loads (older) OpenSSL libraries from the PATH, or it can't find the OpenSSL libraries you've provided.In QtCreator you can check the modules panel to see what libraries are loaded by your application.
Keep in mind that when you run your application from within QtCreator, the run directory isn't the directory the exe relies. For a deployed application it's fine to also deploy the libraries next to your exe.
What Qt version are you actually using?
What OpenSSL version did you try to copy? -
Where can I find the modules panel?
I'm using Qt version 5.2.2, and my OpenSSL version is OpenSSL v1.0.2n.I tried running the program from the .exe directly, which has both openssl dlls in its directory, however it seems like the same error is still occurring there. I checked this by just setting a labels text to reply->readAll(), which resulted in an empty label with nothing in it.
-
@TheMushroom
oh... the Modules panel is hidden by default.
You can make it visible from the menu (Window -> Views -> Modules)Did you override the run environment (in the project settings) - specifically the PATH variable - maybe?
-
Hi,
To add to @raven-worx, are you sure that your OpenSSL libraries are built for MinGW and in 32 bit ?
-
@SGaist
OpenSSL binaries should only expose a C-interface, so there shouldn't be a problem regarding this.
I know that the 1.1.x libraries do append-x64
in the library filename, but i don't know if that was also the case prior v1.1.x -
@raven-worx
For some reason my Window->Views button is greyed out and can't be clicked.Is this the "project settings" tab? :
Screenshot
There doesn't seem to be any upper case PATH value, only a "Path" one.@SGaist
I'm not sure what they were compiled for actually. I downloaded them off this site. -
@TheMushroom said in Getting "qt.network.ssl: QSslSocket: cannot call unresolved function..." when trying to send network request:
For some reason my Window->Views button is greyed out and can't be clicked.
you need to be in the Debug view (big Tab selected on the left side), then the menu item is enabled.
Is this the "project settings" tab? :
yes. Your environment isn't overridden.
I downloaded them off this site.
I just used OpenSSL today successfully with Qt 5.10.1 and mingw. I've downloaded it from here.
-
@raven-worx indeed there shouldn't. However it's usually better to have everything from one compiler if possible to avoid surprises.
I was also thinking about 32 VS 64 bit builds.
-
@raven-worx
How would I link the OpenSSL to Qt?I tried using the "Add Library..." feature in Qt, which generated the following lines in my .pro file:
win32:CONFIG(release, debug|release): LIBS += -LD:/OpenSSL-Win32/lib/MinGW/ -lssl-1_1 else:win32:CONFIG(debug, debug|release): LIBS += -LD:/OpenSSL-Win32/lib/MinGW/ -lssl-1_1d else:unix: LIBS += -LD:/OpenSSL-Win32/lib/MinGW/ -lssl-1_1 INCLUDEPATH += D:/OpenSSL-Win32/include DEPENDPATH += D:/OpenSSL-Win32/include win32:CONFIG(release, debug|release): LIBS += -LD:/OpenSSL-Win32/lib/ -llibcrypto else:win32:CONFIG(debug, debug|release): LIBS += -LD:/OpenSSL-Win32/lib/ -llibcryptod else:unix: LIBS += -LD:/OpenSSL-Win32/lib/ -llibcrypto INCLUDEPATH += D:/OpenSSL-Win32/include DEPENDPATH += D:/OpenSSL-Win32/include
I also added the libssl-1_1.dll and libcrypto-1_1.dll into the same places as I did with the libeay32.dll and ssleay32.dll files.
Still the same errors :(
-
You don't link. By default Qt loads the OpenSSL .dll.
However from the looks of it, you downloaded the 1.1 series which is not compatible with the 1.0.
-
@TheMushroom said in Getting "qt.network.ssl: QSslSocket: cannot call unresolved function..." when trying to send network request:
How would I link the OpenSSL to Qt?
for that you would have to reconfigure and recompile Qt. As @SGaist said by default the OpenSSL libs are loaded dynamically.
What does the modules view show now?
-
@SGaist
Downloaded the 1.0 version and copied the libeay32.dll, ssleay32.dll and libssl32.dll to the same places as before and it's all working now. No errors and everything seems to be working.@SGaist @raven-worx
Thanks a lot for the help! :) -
@TheMushroom great you solved your problem. Please don't forget to mark your post as such. Thanks.
-
@QtFlorian
Do you have@TheMushroom said in Getting "qt.network.ssl: QSslSocket: cannot call unresolved function..." when trying to send network request:
libeay32.dll, ssleay32.dll and libssl32.dll
dlls in your application?
-
@Jasmin-Quinn Qt Online Installer and Qt Maintenance Tool provide the possibility to install OpenSSL, use that.
-
@TheMushroom can you please tell me where did you place them exactly and from where u downloaded it