Qt 6.8 Duplicate symbol: qInitResources
-
Hi,
My Qt application has seperate cmake files for windows build & android build.
Recently , I have updated to 6.8, and after that android build fails with below errors :
ld.lld: error: duplicate symbol: qInitResources_resources()
defined at qrc_resources.cpp:981 (amc_v4_android/.qt/rcc/qrc_resources.cpp:981)
CMakeFiles/amc_v4_android.dir/amc_v4_android/.qt/rcc/qrc_resources.cpp.o:(qInitResources_resources())
defined at qrc_resources.cpp:981 (amc_v4_android_autogen/MU24V53QS3/qrc_resources.cpp:981)
CMakeFiles/amc_v4_android.dir/amc_v4_android_autogen/MU24V53QS3/qrc_resources.cpp.o:(.text._Z24qInitResources_resourcesv+0x0)ld.lld: error: duplicate symbol: qCleanupResources_resources()
defined at qrc_resources.cpp:990 (amc_v4_android/.qt/rcc/qrc_resources.cpp:990)
CMakeFiles/amc_v4_android.dir/amc_v4_android/.qt/rcc/qrc_resources.cpp.o:(qCleanupResources_resources())
defined at qrc_resources.cpp:990 (amc_v4_android_autogen/MU24V53QS3/qrc_resources.cpp:990)
CMakeFiles/amc_v4_android.dir/amc_v4_android_autogen/MU24V53QS3/qrc_resources.cpp.o:(.text._Z27qCleanupResources_resourcesv+0x0)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.My cmake file :
*cmake_minimum_required(VERSION 3.20)qt_add_resources(amc_v4_android "resources"
PREFIX "/"
FILES
../amc/qml/amc.qrc
../localizations/localizations.qrc
../packages/servicetools-components/shared/mobile.qrc
../packages/servicetools-components/shared/assets.qrc
../packages/servicetools-components/ui-strings/ui-strings.qrc
../packages/kmt-protocols/javascript/auth_v2.qrc
../packages/kmt-protocols/javascript/auth_v4.qrc
../packages/kmt-protocols/javascript/avnp.qrc
../packages/kmt-protocols/javascript/dmif.qrc
../packages/kmt-protocols/javascript/d200st.qrc
../packages/kmt-protocols/javascript/failif.qrc
../packages/kmt-protocols/javascript/mcds.qrc
../packages/kmt-protocols/javascript/scc.qrc
../packages/kmt-protocols/javascript/servicetool.qrc
../packages/kmt-protocols/javascript/spade.qrc
../packages/kmt-protocols/javascript/stif.qrc
../packages/kmt-protocols/javascript/est.qrc
../base/base.qrc
../SoftwareLicenses/softwarelicenses_android.qrc
)target_include_directories(amc_v4_android PUBLIC
${PACKAGES_INCLUDES}
${BASE_CODE_DIR}
....
)target_link_libraries(amc_v4_android PUBLIC
${PACKAGES_LIBRARIES}
product
base
suite
door-tool
group-tool
legacy-group-tool
lift-tool
lio-tool
Qt::Core
Qt::Gui
Qt::Qml
Qt::Quick
Qt::Svg
Qt::Xml
)Gather the required libraries
list(APPEND android_extra_libs
${PROJECT_SOURCE_DIR}/packages/openssl/3.0.0/${ANDROID_ABI}/libcrypto_3.so
${PROJECT_SOURCE_DIR}/packages/openssl/3.0.0/${ANDROID_ABI}/libssl_3.so
)Get version string from version header
file(STRINGS ${PROJECT_SOURCE_DIR}/version/version.h VERSION_DEFINITION REGEX "VERSION_STRING")
string(REGEX MATCH "[0-9\.]+" AMC_VERSION "${VERSION_DEFINITION}")Tell Qt6 to use the correct source, libraries, sdk etc.
set_target_properties(amc_v4_android PROPERTIES
QT_ANDROID_PACKAGE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/android"
QT_ANDROID_EXTRA_LIBS "${android_extra_libs}"
QT_ANDROID_MIN_SDK_VERSION 31
QT_ANDROID_TARGET_SDK_VERSION 33
QT_ANDROID_VERSION_NAME "${AMC_VERSION}"
)*Please provide support to resolve the issue.
-
-
@Parvathy2020 Thanks @Christian-Ehrlicher Thanks for the information. The bug report page about the same issue that I face.
So this was a known issue /bug & it is mentioned in the page that fix for the issue is already available with Qt 6.8.But I am using latest Qt 6.8 which I installed 3 days back. But still I get the error.
Also as mentioned in the page, I have removed the set(CMAKE_AUTOUIC ON) , set(CMAKE_AUTOMOC ON) and set(CMAKE_AUTORCC ON) from my code.
Is there any other changes to be made to resolve the issue.
Thanks in advance.
-
@Parvathy2020 said in Qt 6.8 Duplicate symbol: qInitResources:
But I am using latest Qt 6.8 which I installed 3 days back.
How? Did you compile from source? Otherwise you're using Qt6.8.0 which does not contain the fix.
But you can apply them manually - it's only six additional lines in a cmake script. -
@Christian-Ehrlicher Oh yes, my bad , I am using 6.8.0. So the fix is not available with that.
Got it now.Is this the change that need to be added in src/corelib/Qt6CoreMacros.cmake ?
Any change required to be added in my application cmake file ?
-
@Parvathy2020 said in Qt 6.8 Duplicate symbol: qInitResources:
Any change required to be added in my application cmake file ?
Why - the bug report clearly states that the fix from gerrit fixes the problem.
-
Thanks @Christian-Ehrlicher ! The error got solved now. I have updated Qt6CoreMacros.cmake file with the change . Thanks !
When will fix for this issue will be available with Qt 6.8.0 ?
-
@Parvathy2020 Just look at "Fix Version/s:" in the bug ticket
-
-
@jsulm Yes, from the fix versions , it is seen that fix available in 6.5.8, 6.8.1, 6.9.0 FF .
But I have installed 6.8.0 LTS version . Will the fix for this will be available to 6.8.0 any time later or is it required to upgrade to 6.8.1. What is the suggested solution ?
-
@Parvathy2020 said in Qt 6.8 Duplicate symbol: qInitResources:
ill the fix for this will be available to 6.8.0 any time later or is it required to upgrade to 6.8.1.
As you already wrote it's available in 6.8.1 so how should it magically go into the already released 6.8.0 version then?
-
@Parvathy2020 said in Qt 6.8 Duplicate symbol: qInitResources:
But I have installed 6.8.0 LTS version
If 6.8 is a LTS version then also all 6.8.x versions are LTS and you should anyway upgrade to these versions to get all the bug fixes.