Problem with include openssl on Qt Andrioid
-
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
The bug with headers has resolved, but although intelisense can see functions, the application still does not build
Because you also need to say that you are using the libs ;)
Add this in your PRO file:LIBS += -llibcrypto -llibssl
@KroMignon It did not help :(
-
@KroMignon It did not help :(
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
It did not help :(
It seems that you have to specify the location of the libs to avoid error error: cannot find XXX
According to your posts, you are using Qt 5.15 for Android, so I would suggest to do it as follow:CONFIG(release, debug|release): SSL_PATH = /home/john/openssl_test else: SSL_PATH = /home/john/openssl_test/no-asm contains(ANDROID_TARGET_ARCH, armeabi-v7a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm contains(ANDROID_TARGET_ARCH, arm64-v8a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm64 contains(ANDROID_TARGET_ARCH, x86): SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86 contains(ANDROID_TARGET_ARCH, x86_64) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86_64 LIBS += -L$$SSL_PATH -llibcrypto LIBS += -L$$SSL_PATH -llibssl
-
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
It did not help :(
It seems that you have to specify the location of the libs to avoid error error: cannot find XXX
According to your posts, you are using Qt 5.15 for Android, so I would suggest to do it as follow:CONFIG(release, debug|release): SSL_PATH = /home/john/openssl_test else: SSL_PATH = /home/john/openssl_test/no-asm contains(ANDROID_TARGET_ARCH, armeabi-v7a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm contains(ANDROID_TARGET_ARCH, arm64-v8a) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/arm64 contains(ANDROID_TARGET_ARCH, x86): SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86 contains(ANDROID_TARGET_ARCH, x86_64) : SSL_PATH = $$SSL_PATH/Qt-5.12.4_5.13.0/x86_64 LIBS += -L$$SSL_PATH -llibcrypto LIBS += -L$$SSL_PATH -llibssl
@KroMignon said in Problem with include openssl on Qt Andrioid:
LIBS += -L$$SSL_PATH -llibcrypto
LIBS += -L$$SSL_PATH -llibsslIt should be
LIBS += -L$$SSL_PATH -lcrypto LIBS += -L$$SSL_PATH -lssl
(without lib prefix).
@Creatorczyk -
@KroMignon said in Problem with include openssl on Qt Andrioid:
LIBS += -L$$SSL_PATH -llibcrypto
LIBS += -L$$SSL_PATH -llibsslIt should be
LIBS += -L$$SSL_PATH -lcrypto LIBS += -L$$SSL_PATH -lssl
(without lib prefix).
@Creatorczyk -
@jsulm said in Problem with include openssl on Qt Andrioid:
It should be
LIBS += -L$$SSL_PATH -lcrypto
LIBS += -L$$SSL_PATH -lssl(without lib prefix).
Thanks :)
@KroMignon @jsulm I was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:
-
@KroMignon @jsulm I was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:
This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with
include(c:/Android/android-sdk/android_openssl/openssl.pri)
.As APK file is a ZIP archive, you could verify the openSSL libs are include.
You could also try to add them by adding following code in your PRO file:
ANDROID_EXTRA_LIBS += \ $SSL_PATH/libcrypto.so \ $SSL_PATH/libssl.so
-
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:
This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with
include(c:/Android/android-sdk/android_openssl/openssl.pri)
.As APK file is a ZIP archive, you could verify the openSSL libs are include.
You could also try to add them by adding following code in your PRO file:
ANDROID_EXTRA_LIBS += \ $SSL_PATH/libcrypto.so \ $SSL_PATH/libssl.so
@KroMignon said in Problem with include openssl on Qt Andrioid:
ANDROID_EXTRA_LIBS +=
$SSL_PATH/libcrypto.so
$SSL_PATH/libssl.soI changed to
ANDROID_EXTRA_LIBS += \ $$SSL_PATH/libcrypto.so \ $$SSL_PATH/libssl.so
And it works. Thanks!!
-
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
was able to build a project thanks to your tips, but I am having trouble running the application on my phone now. During "Run" the application crashes and issues the following message:
This message means libcrypto.so is not included in you APK, which looks strange to me, because this should be done with
include(c:/Android/android-sdk/android_openssl/openssl.pri)
.As APK file is a ZIP archive, you could verify the openSSL libs are include.
You could also try to add them by adding following code in your PRO file:
ANDROID_EXTRA_LIBS += \ $SSL_PATH/libcrypto.so \ $SSL_PATH/libssl.so
@KroMignon Hi, unfortunately I still have a problem. I've changed repository locations and want to run the project. Building is successful, but again there was a problem running the application on the phone:
My pro file:
Application output:
It is the same error as before, despite the added:
The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?
-
@KroMignon Hi, unfortunately I still have a problem. I've changed repository locations and want to run the project. Building is successful, but again there was a problem running the application on the phone:
My pro file:
Application output:
It is the same error as before, despite the added:
The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?
The error you have is clear, the library
libcrypto.so
is not part of your APK, and cannot be found at application start.
Are you sureSSL_PATH
is what it should be?
you could addmessage(SSL_PATH is $$SSL_PATH)
to show what you have configured. -
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
The project in the old location works without any problems. It appeared while moving the repository to a different path. How could I fix it?
The error you have is clear, the library
libcrypto.so
is not part of your APK, and cannot be found at application start.
Are you sureSSL_PATH
is what it should be?
you could addmessage(SSL_PATH is $$SSL_PATH)
to show what you have configured.@KroMignon I resolved problem by check checkboxes in Build Steps with archictures. Thanks
-
@Creatorczyk said in Problem with include openssl on Qt Andrioid:
I use Qt 5.15.2, maybe it's couse of problem
AFAIK, you have to install open ssl libs with help Qt Creator.
In Tools / Options select Devices and go to tab Android
There you will find a button called "Download OpenSSL"
[EDIT]: After that you have to include the libs in your PRO / CMakeLists.txt file as explained here: https://doc.qt.io/qt-5/android-openssl-support.html#using-openssl-libraries-with-qt-for-android
In my case it would be
- for qmake:
android: include(c:/Android/android-sdk/android_openssl/openssl.pri)
- for cmake:
if (ANDROID) include(c:/Android/android-sdk/android_openssl/CMakeLists.txt) endif()
@KroMignon said in Problem with include openssl on Qt Andrioid:
for qmake
Thank you very much!
QT += core gui websockets widgets android: include(C:/Qt/Tools/OpenSSL-1.1.1j/Win_x64/bin/openssl.pri) CONFIG += c++17 SOURCES += \ main.cpp
I have deployed a simple server example with Box2D-WASM in JavaScript on free Glitch hosting: https://glitch.com/edit/#!/merciful-regal-soursop from the GitHub repository: send-gravity-from-server-to-client-box2d-wasm-js This example sends the gravity value in JSON format when a client is connected. The following example is a client that works on Android, Desktop, and Web (with Qt WebAssembly). It is useful example to make multiplayer games with physics on the server side:
Output:
connected "{\"action\":\"scGravity\",\"data\":\"{\\\"x\\\":0,\\\"y\\\":-3}\"}"
main.cpp
#include <QtNetwork/QNetworkRequest> #include <QtWebSockets/QWebSocket> #include <QtWidgets/QApplication> #include <QtWidgets/QWidget> class Widget : public QWidget { Q_OBJECT public: Widget() { setWindowTitle("Show gravity from server with Box2D-WASM"); resize(420, 200); connect(&m_webSocket, &QWebSocket::connected, this, &Widget::onConnected); connect(&m_webSocket, &QWebSocket::textMessageReceived, this, &Widget::onMessageReceived); connect(&m_webSocket, &QWebSocket::errorOccurred, this, &Widget::onErrorOccurred); QUrl url("wss://merciful-regal-soursop.glitch.me"); QNetworkRequest request; request.setUrl(url); request.setRawHeader(QByteArray("User-Agent"), QByteArray("Mozilla/5.0 " "(Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/124.0.0.0 Safari/537.36")); m_webSocket.open(request); } ~Widget() {} private slots: void onConnected() { qDebug() << "connected"; } void onMessageReceived(const QString &message) { qDebug() << message; } void onErrorOccurred(QAbstractSocket::SocketError error) { qDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; qDebug() << "Error:" << error; qDebug() << "Device supports OpenSSL:" << QSslSocket::supportsSsl(); qDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; } private: QWebSocket m_webSocket; }; #include "main.moc" int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w; w.show(); return a.exec(); }