Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Multiple definitions: qInitResources_translations()
Qt 6.11 is out! See what's new in the release blog

Multiple definitions: qInitResources_translations()

Scheduled Pinned Locked Moved Unsolved Qt 6
2 Posts 1 Posters 778 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rich v
    wrote on last edited by Rich v
    #1

    My CMake project produces qrc_translations.cpp files for 3 different QML libraries I use. Each one of these reproduces the same symbol: qInitResources_translations. This is seemingly because QT_NAMESPACE is empty. When it is defined to something, the macro here will make that symbol unique:

    int QT_RCC_MANGLE_NAMESPACE(qInitResources_translations)();
    

    So this is probably a dumb question, but where is QT_NAMESPACE supposed to be defined?

    FWIW, I'm porting from Qt5.6 to 6.x. I had no issues with the previous qt5_add_translation() so I'm probably misusing the new qt_add_translations()?

    Here is the meat of the CMakeLists.txt file that is similar across the three QML libraries. The Qt6_FOUND section is what I seem to be having issues with.

    if (Qt6_FOUND)
        qt_add_library(BCControls STATIC)
        file(GLOB TS_FILES translations/*.ts)
        qt_add_translations(BCControls TS_FILES ${TS_FILES})
        qt_add_qml_module(BCControls
            URI BCControls
            VERSION 1.0
            QML_FILES ${QML_FILES}
            RESOURCES ${RESOURCE_FILES}
            )
    else()
        create_install_plugin_translations(translations
            BCControls/translations
            QM_FILES
            )
        add_library(BCControls STATIC ${QM_FILES})
        qtquick_compiler_add_resources(RESOURCES bccontrols.qrc)
        target_sources(BCControls
            PRIVATE
            ${RESOURCES}
            ${QML_FILES}
            bccontrols.qrc
            )
        foreach(F ${QM_FILES})
            get_filename_component(COPY_FILE ${F} NAME)
            add_custom_command(TARGET BCControls POST_BUILD
                COMMAND ${CMAKE_COMMAND} -E copy ${F} ${CMAKE_INSTALL_PREFIX}/BCControls/translations/${COPY_FILE})
        endforeach()
    endif()
    
    R 1 Reply Last reply
    0
    • R Rich v

      My CMake project produces qrc_translations.cpp files for 3 different QML libraries I use. Each one of these reproduces the same symbol: qInitResources_translations. This is seemingly because QT_NAMESPACE is empty. When it is defined to something, the macro here will make that symbol unique:

      int QT_RCC_MANGLE_NAMESPACE(qInitResources_translations)();
      

      So this is probably a dumb question, but where is QT_NAMESPACE supposed to be defined?

      FWIW, I'm porting from Qt5.6 to 6.x. I had no issues with the previous qt5_add_translation() so I'm probably misusing the new qt_add_translations()?

      Here is the meat of the CMakeLists.txt file that is similar across the three QML libraries. The Qt6_FOUND section is what I seem to be having issues with.

      if (Qt6_FOUND)
          qt_add_library(BCControls STATIC)
          file(GLOB TS_FILES translations/*.ts)
          qt_add_translations(BCControls TS_FILES ${TS_FILES})
          qt_add_qml_module(BCControls
              URI BCControls
              VERSION 1.0
              QML_FILES ${QML_FILES}
              RESOURCES ${RESOURCE_FILES}
              )
      else()
          create_install_plugin_translations(translations
              BCControls/translations
              QM_FILES
              )
          add_library(BCControls STATIC ${QM_FILES})
          qtquick_compiler_add_resources(RESOURCES bccontrols.qrc)
          target_sources(BCControls
              PRIVATE
              ${RESOURCES}
              ${QML_FILES}
              bccontrols.qrc
              )
          foreach(F ${QM_FILES})
              get_filename_component(COPY_FILE ${F} NAME)
              add_custom_command(TARGET BCControls POST_BUILD
                  COMMAND ${CMAKE_COMMAND} -E copy ${F} ${CMAKE_INSTALL_PREFIX}/BCControls/translations/${COPY_FILE})
          endforeach()
      endif()
      
      R Offline
      R Offline
      Rich v
      wrote on last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved