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. My QtQuick 2 extension plugin shared library is not compiling.

My QtQuick 2 extension plugin shared library is not compiling.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 800 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.
  • Y Offline
    Y Offline
    yegender
    wrote on last edited by
    #1

    Hi,
    I want to make a shared library of my project. As default qt creator generates a static library from the generated CMakeLists.txt. When I changed it to the SHARED I got this error:
    CMakeLists.txt:33: error: Target "IgniteUIplugin" of type MODULE_LIBRARY may not be linked into another target. One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables with the ENABLE_EXPORTS property set.

    and Here is my CMakeLists.txt

    cmake_minimum_required(VERSION 3.16)
    
    project(IgniteUI 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 Quick REQUIRED)
    
    qt_add_library(IgniteUI SHARED)
    qt_add_qml_module(IgniteUI
        URI IgniteUI
        VERSION 1.0
        QML_FILES IgniteUIControls.qml
        SOURCES igniteui.cpp igniteui.h
    )
    
    target_compile_definitions(IgniteUI
        PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    target_link_libraries(IgniteUI
        PRIVATE Qt6::Quick)
    
    target_include_directories(IgniteUI PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
    
    # Example Project
    qt_add_executable(ExampleProject example/example.cpp)
    qt_add_qml_module(ExampleProject
        URI ExampleProjectApp
        VERSION 1.0
        QML_FILES example/example.qml
    )
    target_link_libraries(ExampleProject PRIVATE Qt6::Quick IgniteUIplugin)
    target_compile_definitions(ExampleProject PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
    

    Cheers

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      yegender
      wrote on last edited by
      #2

      I think this line in my example.cpp:

      Q_IMPORT_QML_PLUGIN(IgniteUIPlugin)
      

      is causing these issues. maybe it requires the static library and I am providing it the shared library. Does there is a way to make it to use the shared instead of the static library.

      Cheers

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yegender
        wrote on last edited by
        #3

        I fixed it by removing that line and added the full path of the library

        1 Reply Last reply
        0
        • G Offline
          G Offline
          glarkham
          wrote on last edited by
          #4

          Don't mean to necro-post, but this forum came up on google and I found a more satisfying solution to the same problem for me.

          In the CMakeLists.txt file where I define the plugin, I simply added the following:

          qt_add_library(PressureModel STATIC)
          

          To indicate the library as static rather than MODULE_LIBRARY.

          Full CMakeLists.txt file I used for reference:

          find_package(Qt6 REQUIRED COMPONENTS RemoteObjects)
          
          qt_add_library(PressureModel STATIC)
          qt6_add_qml_module(PressureModel
              URI PressureModel
              VERSION 1.0
              SOURCES
                  PressureModel.cpp
                  PressureModel.h
              RESOURCE_PREFIX "/"
          )
          
          qt6_add_repc_replicas(PressureModel PressureModel.rep)
          
          target_link_libraries(PressureModel PUBLIC Qt6::RemoteObjects)
          
          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