Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.7
-
None
Description
Consider the following CMake code:
set(CMAKE_CXX_FLAGS "-Wl,-as-needed") add_executable(foo main.cpp) add_library(bla SHARED) qt_add_qml_module(bla URI "org.kde.bla" NO_PLUGIN VERSION 0.1 QML_FILES MyThing.qml) target_link_libraries(foo PRIVATE bla Qt::Qml Qt::Gui)
By linking against bla I expect MyThing.qml to be available in the resources of the app. However that's not the case, because bla is discarded by the linker because it appears as not needed (nothing in foo references symbols in bla).
Some toolchains default to "-as-needed", making the problem very not obvious. Now I guess this isn't strictly a Qt bug, but I still wonder if there's something Qt can do, if only document the pitfall.
There is Q_IMPORT_QML_PLUGIN, but that appears to be only for static builds with plugins, but here I have neither a static build nor a plugin
Attachments
Issue Links
- relates to
-
QTBUG-95149 Fix use case of linking an executable to a shared library QML module backing target
- Reported