Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Can't create QApplication for ios using cmake build
Forum Updated to NodeBB v4.3 + New Features

Can't create QApplication for ios using cmake build

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paltoquet
    wrote on last edited by Paltoquet
    #1

    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-cmake

    if 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 arm64

    in this bug report:
    https://bugreports.qt.io/browse/QTBUG-50986

    He 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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Paltoquet
      wrote on last edited by Paltoquet
      #2

      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

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved