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:

    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);
        // main loop
        QQmlApplicationEngine engine;
        return app.exec();

    and the main.qml:

    import QtQuick 2.7
    import QtQuick.Controls 2.0
            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

    if i replace my main

    int main(int argc, char **argv)


    extern "C" int qtmn(int argc, char *argv[])

    i got this error
    entry point (_main) undefined. for architecture arm64

    in this bug report:

    He suggest to keep the

    int main(int argc, char **argv)

    I also found this post dealing with the same problem

    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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.