Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Plugin error while loading in application uisng cmake
Qt 6.11 is out! See what's new in the release blog

Plugin error while loading in application uisng cmake

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 746 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
    Rangantha B V
    wrote on last edited by
    #1

    hai i am trying crete a simple plugin using CMakeList.txt in windows. but i ma facing an error i tried so many ways but i am not getting how to resolved this error please hepl me to resolve this.

    cmake_minimum_required(VERSION 3.16)
    
    project(WComponents VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(QT_QML_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR})
    
    find_package(Qt6 6.2 COMPONENTS Core Quick REQUIRED)
    find_package(Qt6 REQUIRED COMPONENTS Core )
    
    # qt_add_library(WComponents STATIC)
    qt_add_qml_module(WComponents
        URI "com.WComponents"
        CLASS_NAME WComponentsPlugin
        PLUGIN_TARGET WComponentsPlugin
        VERSION 1.0
        QML_FILES CustomBtn.qml
        SOURCES
        WComponents_plugin.cpp
        WComponents_plugin.h
        WAction.h
        WAction.cpp
    )
    
    set_target_properties(WComponents PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_compile_definitions(WComponents
        PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(WComponents
        PRIVATE
        Qt6::Quick
        Qt6::Core
    )
    target_link_libraries(WComponents PRIVATE Qt6::Core)
    # target_link_libraries(WComponents PRIVATE Qt6::Core)
    
    target_include_directories(WComponents PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
    
    

    this is my plugin cmake .
    i am not added anything in application cmake but in main.cpp i am loading using

    enine.addImportPath("D:\\rangaWorkspace\\WComponentsLoader")
    

    and in my main.qml i am iporting like this

    import com.WComponents 1.0
    or
    import com.WComponents
    
    

    but when i launch my application i am getting below error

    QQmlApplicationEngine failed to load component
    qrc:/qt/qml/WComponentsLoader/Main.qml:2:1: Cannot load library D:\rangaWorkspace\WComponentsLoader\com\WComponents\WComponentsPlugin.dll: The specified module could not be found.
    

    please help me to resolve this error.
    ThankYou.

    jsulmJ 1 Reply Last reply
    0
    • R Rangantha B V

      hai i am trying crete a simple plugin using CMakeList.txt in windows. but i ma facing an error i tried so many ways but i am not getting how to resolved this error please hepl me to resolve this.

      cmake_minimum_required(VERSION 3.16)
      
      project(WComponents VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      set(QT_QML_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR})
      
      find_package(Qt6 6.2 COMPONENTS Core Quick REQUIRED)
      find_package(Qt6 REQUIRED COMPONENTS Core )
      
      # qt_add_library(WComponents STATIC)
      qt_add_qml_module(WComponents
          URI "com.WComponents"
          CLASS_NAME WComponentsPlugin
          PLUGIN_TARGET WComponentsPlugin
          VERSION 1.0
          QML_FILES CustomBtn.qml
          SOURCES
          WComponents_plugin.cpp
          WComponents_plugin.h
          WAction.h
          WAction.cpp
      )
      
      set_target_properties(WComponents PROPERTIES
          MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
          MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
          MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
          MACOSX_BUNDLE TRUE
          WIN32_EXECUTABLE TRUE
      )
      
      target_compile_definitions(WComponents
          PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
      target_link_libraries(WComponents
          PRIVATE
          Qt6::Quick
          Qt6::Core
      )
      target_link_libraries(WComponents PRIVATE Qt6::Core)
      # target_link_libraries(WComponents PRIVATE Qt6::Core)
      
      target_include_directories(WComponents PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
      
      

      this is my plugin cmake .
      i am not added anything in application cmake but in main.cpp i am loading using

      enine.addImportPath("D:\\rangaWorkspace\\WComponentsLoader")
      

      and in my main.qml i am iporting like this

      import com.WComponents 1.0
      or
      import com.WComponents
      
      

      but when i launch my application i am getting below error

      QQmlApplicationEngine failed to load component
      qrc:/qt/qml/WComponentsLoader/Main.qml:2:1: Cannot load library D:\rangaWorkspace\WComponentsLoader\com\WComponents\WComponentsPlugin.dll: The specified module could not be found.
      

      please help me to resolve this error.
      ThankYou.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Rangantha-B-V No need to ask same question twice (https://forum.qt.io/topic/163207/qml-plugin-load-error/4?_=1757653705393).
      In that other thread - did you react to the comment from @JKSH ?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Axel SpoerlA Axel Spoerl locked this topic on

      • Login

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