Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Create a shared library without resolving functions or a QPluginLoader interface
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Create a shared library without resolving functions or a QPluginLoader interface

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    Threadcore
    wrote on last edited by
    #1

    Hello there

    In the past few days I played with shared and static libraries, QPlugin and QPluginLoader. Now I think it's the time to use these information in a project.

    The plan: I have an application and a backend (shared library). The shared library contains signal and slots and has more than 250 methods. At the moment I link it statically - so exporting is not a problem.

    Now I run into the problem of a shared library:

    • Create a normal shared library and resolve more than 250 methods. Can I use signal and slots or do I have to use the extern C functions (Like the QPlugin example here: "How to create plugins":http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application?
    • Write an interface with 250 virtual functions (Overhead) and a class. Use QPluginLoader to load it at runtime

    So as you can see I need the possibility of the QPluginLoader without the interface (Because the plan is to write a shared library and not an abstract plugin interface). My questions:

    • Is it possible to use a shared library without an interface in combination with QPluginLoader. The solution has to work under windows (Unix-only would be very easy)
    • If not, are there any other solutions ?

    Thank you in advice,
    Threadcore

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Are you planning to give the means to link to your library along your library ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Threadcore
        wrote on last edited by
        #3

        Hi SGaist

        I have the possibility to link against the (shared) library. I develop both components and deploy both in the same package.

        I use CMake as a build system and under Unix is is possible to create a shared library with add_library(xyz SHARED ...) and put them in the library directory - very nice. But this does not work for windows - so that's my problem

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you can use the technique described "here":http://qt-project.org/doc/qt-4.8/sharedlibrary.html

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Threadcore
            wrote on last edited by
            #5

            Ok, thank you, with the Q_DECL_EXPORT/Q_DECL_IMPORT it works like a charm under windows.

            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