Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.3.0
-
None
Description
Creating a cmake project to build a simple shared lib for iOS, after that adding Qt::StateMachine usage into cmake:
cmake_minimum_required(VERSION 3.14) project(sharedlib LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core StateMachine) add_library(sharedlib SHARED sharedlib_global.h sharedlib.cpp sharedlib.h) target_link_libraries(sharedlib PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt::StateMachine) target_compile_definitions(sharedlib PRIVATE SHAREDLIB_LIBRARY)
I got this linked issue:
Undefined symbols for architecture arm64: "_main", referenced from: user_main_trampoline() in libqios.a(qioseventdispatcher.mm.o)
After a while, I realized that the root cause is Qt::StateMachine depends on Qt::Gui and Qt::Gui requires a define main() method. I tried to remove this dependency in some cmake files inside <qt_install_path>/6.3.0/ios/lib/cmake/Qt6StateMachine/ folder, my build succeeds now.
I'm migrating from Qt 5.15.0 to 6.3.0 and I know you guys have added a feature of event transition into StateMachine module which depends on Gui module, but in theory, I think the core part of StateMachine should not depends on Gui. Can you please add a simple way to bypass this problem, like a build option to disable that dependency (to Gui) when I don't need it? Thanks!