Important: Please read the Qt Code of Conduct -

Main function required when compiling shared library for iOS?

  • I have a project made of 3 subdirectories which are built in order as follows

    • Static library (uses QT)
    • Shared library (also uses QT)
    • QML Application

    The static library is used by the shared library which is used by the QML Application

    Everything builds perfectly fine and runs on Android and MacOS. However, when I go to build for iOS I get the following error when compiling the shared library:

    Undefined symbols for architecture armv7:
      "_main", referenced from:
          user_main_trampoline() in libqios_debug.a(qioseventdispatcher.o)
         (maybe you meant: _jinit_d_main_controller, _jinit_c_main_controller , _qt_main_wrapper )

    The static library builds fine and if I change the shared library to being static, it also compiles fine, but ends up being far too large for practical use and it is a project constraint that this library remain a shared library.

    All I can really assume is that the shared library is being compiled as if it were an application? I'm under this presumption because changing the library from static to shared causes QT Creator to add a run option for the shared library, i.e "Run [Shared Library] on iOS Simulator." That and the fact that the error above means a main function wasn't found (it's a shared library, duh).

    I am using QT 5.9 and QT Creator 4.3.0, Xcode updated this morning.

    Is this a bug or a limitation of QT?

  • Qt Champions 2017

    iOS uses static library only. So you may need to use static library. You can look at my post on this plugin stuff. I heard u can use shared plugin qt 5.9 and have no used it.

  • Moderators

    I came here to say exactly what @dheerendra said, lol.

    It's not a bug or limitation of Qt but more a limitation of iOS which does not allow shared objects or dylibs as apple calls them.

  • Lifetime Qt Champion


    To add to my fellow developer (and as it's explained in the thread @dheerendra is referring to). The current build is static as per the old rules of the Apple store, this rule has now been relaxed so one possibility would be to re-build Qt 5.9 dynamically yourself however, as explained in the link I posted in @dheerendra thread, full tooling support is not completely there yet so you might how some more work to do to release your application.

  • Yeah, I figured that since Apple has permitted shared libraries since iOS 8.0 in late 2014 that QT might support their use.

    Unfortunately for me, after waiting quite a bit for QT to partially compile as a shared library I discovered that this doesn't even work for now. 5.9, as released can't be compiled as a shared library for iOS because of the issues in this report.

    It looks like this won't officially be working until the release of 5.9.1, which is marked for June, so hopefully we'll see a release in the next week.

Log in to reply