Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Dynamic selection of static lib to extend class?
Forum Update on Monday, May 27th 2025

Dynamic selection of static lib to extend class?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 593 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.
  • A Offline
    A Offline
    apampe
    wrote on 31 May 2017, 15:10 last edited by
    #1

    I'm looking for best practices to accomplish an application that loads compiled "programs" based on a config file, hopefully as a static lib. The main app, loads config.json, parses it which includes a name of a "program". I'd like to have a class Program.cpp that is extended by any one of a number of "programs" that override/implement key functions of how that program performs.

    I believe the way to do this, but wanting to get feedback on the method first, is to have the main program:

    main.cpp
    Program.cpp
    config.json {"program": "MailManager"}

    The compiled executable would be on the server, alongside with the following static libraries:

    MailManager.cpp compiled to programs/MailManager.so
    MailManager_strict.cpp compiled to programs/MailManger_strict.so

    The use case is to be able to, shutdown the main app, modify config.json to use any one of many pre-comiled "programs", and then restart the main app, whereas it'll load a different static library to extend Program based on the config file.

    Thanks for any feedback!

    J 1 Reply Last reply 1 Jun 2017, 05:15
    0
    • A apampe
      31 May 2017, 15:10

      I'm looking for best practices to accomplish an application that loads compiled "programs" based on a config file, hopefully as a static lib. The main app, loads config.json, parses it which includes a name of a "program". I'd like to have a class Program.cpp that is extended by any one of a number of "programs" that override/implement key functions of how that program performs.

      I believe the way to do this, but wanting to get feedback on the method first, is to have the main program:

      main.cpp
      Program.cpp
      config.json {"program": "MailManager"}

      The compiled executable would be on the server, alongside with the following static libraries:

      MailManager.cpp compiled to programs/MailManager.so
      MailManager_strict.cpp compiled to programs/MailManger_strict.so

      The use case is to be able to, shutdown the main app, modify config.json to use any one of many pre-comiled "programs", and then restart the main app, whereas it'll load a different static library to extend Program based on the config file.

      Thanks for any feedback!

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 1 Jun 2017, 05:15 last edited by jsulm 6 Jan 2017, 05:16
      #2

      @apampe Why static libraries? Static libraries are used during linking of your app and are part of your app executable after linking.
      .so are shared libraries not static (static libs have .a extension on Linux).
      What you want to do sounds a lot like plug-ins. Take a look at http://doc.qt.io/qt-5/plugins-howto.html
      Or just create shared libraries (without main!) and load them dynamically using dlopen (but it is easier to use Qt plug-ins).

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

      1 Reply Last reply
      1

      1/2

      31 May 2017, 15:10

      • Login

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