Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.2, 5.12.3, 5.13.0
-
Xcode 10.2
Qt 5.12.3
macOS 10.14.4
Description
Steps to reproduce
- Clone Qt sources
git clone --branch 5.12.3 https://code.qt.io/qt/qt5 cd qt5
- Initialize repositories
perl init-repository --module-subset=default,-qtwebengine --branch
- 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!
- Set environmental variable to allow automatic update of provisioning profiles
export XCODEBUILD_FLAGS = -allowProvisioningUpdates
- Configure build (with -shared option!)
./configure -xplatform macx-ios-clang -shared -sdk iphoneos -opensource -nomake examples -nomake tests -shared -skip qtwebengine -skip qtwebglplugin
- 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?