Problems with translation files with Qt 6.8
-
Hello, I am currently facing some issue that was not present in 6.7.3. It is related to translation files, when application links I get this error:
duplicate symbol 'qCleanupResources_AbracaDABra_translations()' in: /Users/kejpi/Devel/AbracaDABra/build/Qt_6_8_0_for_macOS-Debug/gui/CMakeFiles/AbracaDABra.dir/AbracaDABra_autogen/JYUKLDW5FZ/qrc_AbracaDABra_translations.cpp.o /Users/kejpi/Devel/AbracaDABra/build/Qt_6_8_0_for_macOS-Debug/gui/CMakeFiles/AbracaDABra.dir/__/.qt/rcc/qrc_AbracaDABra_translations.cpp.o duplicate symbol 'qInitResources_AbracaDABra_translations()' in: /Users/kejpi/Devel/AbracaDABra/build/Qt_6_8_0_for_macOS-Debug/gui/CMakeFiles/AbracaDABra.dir/AbracaDABra_autogen/JYUKLDW5FZ/qrc_AbracaDABra_translations.cpp.o /Users/kejpi/Devel/AbracaDABra/build/Qt_6_8_0_for_macOS-Debug/gui/CMakeFiles/AbracaDABra.dir/__/.qt/rcc/qrc_AbracaDABra_translations.cpp.o
I have this in
CMakeLists.txt
:set(TSFILES l10n/${TARGET}_cs.ts l10n/${TARGET}_de.ts l10n/${TARGET}_pl.ts ) qt_add_translations(${TARGET} TS_FILES ${TSFILES} LUPDATE_OPTIONS "-noobsolete" )
If I comment out
qt_add_translations
macro then it links file but translation does not work.I have also found out that if I keep
qt_add_translations
but removeqt_finalize_target(${TARGET})
it works too.
I needqt_finalize_target(${TARGET})
to make "allow location permissions" dialog working on macOS.Problem is not macOS related, the problem is on Linux too: https://github.com/KejPi/AbracaDABra/issues/171
Everything is working fine with Qt < 6.8.
Do you have any idea how to fix it? -
seem to this fix:
https://codereview.qt-project.org/c/qt/qtbase/+/601223 -
Thanks for pointing that out, that is exactly the issue I have.
According to related bug report I have removedset(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON)
and replaced them by:
qt_standard_project_setup()
This seems to work for Qt 6.8.0 and also lower version (tested with 6.5.3).
I am marking this issue as solved, thank you!
-