Important: Please read the Qt Code of Conduct -

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__@@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...

    <qresource "/myresources">

    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.

  • Thank you very much!! Worked awesome !!

Log in to reply