Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75457

Missing symbol lcEventDispatcher when building Qt for iOS from source as shared library

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.2, 5.12.3, 5.13.0
    • Core: Event loop
    • Xcode 10.2
      Qt 5.12.3
      macOS 10.14.4
    • iOS/tvOS/watchOS

    Description

      Steps to reproduce

      1. Clone Qt sources
         
        git clone --branch 5.12.3 https://code.qt.io/qt/qt5 
        cd qt5 
        
      2. Initialize repositories
         
        perl init-repository --module-subset=default,-qtwebengine --branch 
        
      3. If your Apple Account also does not like the profile "com.yourcompany" you have to change it manually to something else:
        Open file
        <source-code-dir>/qt5/qtbase/mkspecs/features/mac/default_post.prf

        and search for the line

        xcode_product_bundle_identifier_setting.value = "com.yourcompany"

        Modify it to "com.mycompany" (for example). Make sure to add this profile to your Apple-ID!

      4. Set environmental variable to allow automatic update of provisioning profiles
         
        export XCODEBUILD_FLAGS = -allowProvisioningUpdates 
        
      5. Configure build (with -shared option!)
         
        ./configure -xplatform macx-ios-clang -shared -sdk iphoneos -opensource -nomake examples -nomake tests -shared -skip qtwebengine -skip qtwebglplugin 
        
      6. Compile code
         
        make -j 4 
        

      Actual behaviour

      When qmltime gets linked, the linker throws an error that the symbol lcEventDispatcher() is not defined:

       
      Undefined symbols for architecture arm64: 
        "lcEventDispatcher()", referenced from: 
            _qt_main_wrapper in libqios.a(qioseventdispatcher.o) 
            +[QIOSApplicationStateTracker applicationDidFinishLaunching:] in libqios.a(qioseventdispatcher.o) 
            user_main_trampoline() in libqios.a(qioseventdispatcher.o) 
            +[QIOSApplicationStateTracker applicationWillTerminate] in libqios.a(qioseventdispatcher.o) 
            QIOSJumpingEventDispatcher::interruptEventLoopExec() in libqios.a(qioseventdispatcher.o) 
      ld: symbol(s) not found for architecture arm64 
      

      Expected behaviour

      Compilation without any error

      Investigation of the problem

      Searching a lot through the code resulted in the following observations:

      • lcEventDispatcher is declared as extern in qeventdispatcher_cf_p.h
      • lcEventDispatcher gets defined by the macro Q_LOGGING_CATEGORY in qeventdispatcher_cf.mm
      • The symbol cannot be found by the linker because in the compiled framework (<build-directory>/qtbase/lib/QtCore.framework/QtCore) the symbol is defined internal but not external
        This can be validated by using nm tool one time with and one time without the -g option:
         
        nm -g --demangle QtCore.framework/QtCore 
        

      Suggested Bugfix

      Adding Q_CORE_EXPORT in front of the definition of lcEventDispatcher makes the symbol external in the resulting QtCore.framework and fixed the problem for me. In the attachments you can find a patch for the qtbase repository that contains the suggested bugfix.

      Open Questions

      Why does the symbol do not have automatically external linkage when it is declared external and is not defined with the static keyword?

      Attachments

        Activity

          People

            vestbo Tor Arne Vestbø
            christian.fischerauer Christian Fischerauer
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: