Can't create QApplication for ios using cmake build
-
Hi,
I am currently building a qt base project using cmake.
I face some problems during linking but I succeed to remove them following this guide line:https://bugreports.qt.io/browse/QTBUG-47336
Now i am trying to run the app on my ipad but i have this error:
You are creating QApplication before calling UIApplicationMain.
If you are writing a native iOS application, and only want to use Qt for
parts of the application, a good place to create QApplication is from within
'applicationDidFinishLaunching' inside your UIApplication delegate.here is my main:
#include <QtCore/QLibraryInfo> #include <QtCore/QString> #include <QtCore/QTranslator> #include <QtCore/QUrl> #include <QtQml/QQmlApplicationEngine> #include <QtQml/QQmlContext> #include <QtWidgets/QApplication> #include <iostream> #include <QApplication> #include <QtGlobal> // Q_OS_IOS #include <QtCore/QtDebug> int main(int argc, char **argv) { std::cout << "test" << std::endl; QApplication app(argc, argv); app.setApplicationName("Designer"); // main loop QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); return app.exec(); }
and the main.qml:
import QtQuick 2.7 import QtQuick.Controls 2.0 ApplicationWindow{ Rectangle{ anchors.fill: parent color: "red" } }
I find some solutions to this problem but they all were based on some some old version of QT in 2014
https://stackoverflow.com/questions/25042916/run-time-error-for-qt-application-on-ios-built-via-cmakeif i replace my main
int main(int argc, char **argv)
with
extern "C" int qtmn(int argc, char *argv[])
i got this error
entry point (_main) undefined. for architecture arm64in this bug report:
https://bugreports.qt.io/browse/QTBUG-50986He suggest to keep the
int main(int argc, char **argv)
I also found this post dealing with the same problem
https://stackoverflow.com/questions/43002064/qt-xcode-ios-entry-point
I don't know where should I look for a possible answer.
-
I find a fix:
was a bit hard but the solutions is to add -e,_qt_main_wrapper in your LD flags
If you have some qml look at the link
https://stackoverflow.com/questions/45508043/qt-ios-linker-error-entry-point-main-undefined/45617820#45617820