Libs from /qml/* directory not linked
abbetch opened this issue · 2 comments
Library form the ${qt_sdk}/ios/qml/ ... are not added to the linker. Causing a qt creator's cmake project, to not successfully work.
For example ${qt_ios_sdk}/qml/QtQuick.2/libqtquick2plugin.a , ${qt_ios_sdk}/qml/QtQuick/Window.2/libwindowplugin.a seems to be needed are are present when building the makefile with qmake. but arn't there using QtIosCmake.
Ok my guess is that you are not importing the libraries in your project. When building for ios qt is statically linked. But libqtquick2plugin.a
for example is a dynamic plugin. Loaded at execution time. So they are not linked by default. You don't need it to compile and your project doesn't use any symbol from this library. You need to force the use of a symbol. You need a file like this:
#include <QtPlugin>
Q_IMPORT_PLUGIN(QtQuick2Plugin);
Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin);
Q_IMPORT_PLUGIN(QtQuickControls2Plugin);
Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin);
Q_IMPORT_PLUGIN(QtQuick2WindowPlugin);
Q_IMPORT_PLUGIN(QtQuickControls2MaterialStylePlugin);
Q_IMPORT_PLUGIN(QmlSettingsPlugin);
Q_IMPORT_PLUGIN(QtQuickControls2FusionStylePlugin);
Q_IMPORT_PLUGIN(QtQuickControls2UniversalStylePlugin);
Q_IMPORT_PLUGIN(QtQuickControls2ImagineStylePlugin);
Q_IMPORT_PLUGIN(QtGraphicalEffectsPlugin);
Q_IMPORT_PLUGIN(QtGraphicalEffectsPrivatePlugin);
This will force your project to link to at least one function from the plugin. You can find more info in Qt official documentation. qmake generate these files for you under the hood.
You also need to add -u _qt_registerPlatformPlugin
to your linker flag.�
So either you know all the plugin you need and you add these files in your project path. Or you can use my script QtStaticCMake that will generate it for you.
You can take a look at how i integrated these two libraries together in this project.
You can find example of QtStaticCMake in main CMakeLists.txt
line 266
:
qt_generate_qml_plugin_import(${QQUICKMATERIALHELPERGALLERY_TARGET} QML_SRC ${CMAKE_CURRENT_SOURCE_DIR}/qml VERBOSE)
qt_generate_plugin_import(${QQUICKMATERIALHELPERGALLERY_TARGET} VERBOSE)
Usage of QtIosCMake is shown in platform/PostBuildPlatform.cmake
line 57.
IF(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
# We can't have empty flags
IF(NOT TEAM_ID)
SET(TEAM_ID "AAAAAAAA")
ENDIF(NOT TEAM_ID)
add_qt_ios_app(${QQUICKMATERIALHELPERGALLERY_TARGET}
NAME "Qml Material Helper Gallery"
BUNDLE_IDENTIFIER "com.oliv.materialGallery"
VERSION ${QQUICKMATERIALHELPERGALLERY_VERSION}
LONG_VERSION ${QQUICKMATERIALHELPERGALLERY_VERSION}.${QQUICKMATERIALHELPERGALLERY_VERSION_TAG}
CODE_SIGN_IDENTITY "iPhone Developer"
TEAM_ID ${TEAM_ID} # TEAM_ID must be specified when executing cmake or later in XCode
COPYRIGHT "Copyright Olivier Ldff 2019"
ASSET_DIR "${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/Assets.xcassets"
LAUNCHSCREEN_STORYBOARD "${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/LaunchScreen.storyboard"
MAIN_STORYBOARD "${CMAKE_CURRENT_SOURCE_DIR}/platform/ios/Main.storyboard"
ORIENTATION_PORTRAIT
ORIENTATION_PORTRAIT_UPDOWN
ORIENTATION_LANDSCAPE_LEFT
ORIENTATION_LANDSCAPE_RIGHT
SUPPORT_IPHONE
SUPPORT_IPAD
VERBOSE
)
ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "iOS")
I hope this will solve your problem!
Have a nice day.
Keep me up to date if i can close this issue and this fixed your problem.
I consider this issue close.