Problem with 2 different libraries each having it's own rcc file.
-
When I link in 2 different libraries ( which each have a QT resource ) I get the following link errors, names have been changed to protect the innocent....
A.lib(Doit.obj) : error LNK2005: "int cdecl qInitResources(void)" (?qInitResources@@YAHXZ) already defined in B.lib(Foo.obj)
A.lib(Doit.obj) : error LNK2005: "int cdecl qCleanupResources(void)" (?qCleanupResources@@YAHXZ) already defined in B.lib(Foo.obj)
A.lib(Doit.obj) : error LNK2005: "class qCleanupResources__dest_class qCleanupResources__dest_instance" (?qCleanupResources__dest_instance__@@3VqCleanupResources__dest_class__@@A) already defined in B.lib(Foo.obj)The resources include only art and are compiled from a QRC file, example below...
<RCC>
<qresource "/myresources">
<file>images/picture.png</file>
</qresource>
</RCC>Looking at the rcc file I see that both have the lines
int QT_MANGLE_NAMESPACE(qInitResources)() {...}
int QT_MANGLE_NAMESPACE(qCleanupResources)() {...}I am building in VS2005 on Windows XP.
Does any one know how I can resolve this?
-
If you want to link in several resource files compiled with the Qt RCC into the same binary, use the "-name" parameter. And pass a different/unique value to "-name" for each invocation of RCC. This will change the name of the "qInitResources" and "qCleanupResources" functions in the generated code to avoid name conflicts.
-
I don't see what translations should have to do with a duplicate symbol... and this thread was about qmake and not cmake.
Please open a new thread with a valid error description. -
I have same issue when I tried to switch from qt 6.6.3 to 6.8.0.
How to fix in cmake?from my cmake:
qt_add_translations(${PROJECT_NAME}
INCLUDE_DIRECTORIES
${PROJECT_SOURCE_DIR}
TS_FILES
${TS_PROJECT_FILES})