0

I build a plugin based Qt application which currently lives entirely in a library. The app as well as the plugins link to the library. The ::main(…) is just a tiny two line bootstrapper calling a guarded run(…) in the library. Most of the interface classes are Pimpl or virtual interfaces, however there are loads of classes in the library that are not related to the interface but are simply part of the core app.

I use this approach because somebody told me years ago that exporting symbols from the executable is not possible . Over the years I failed several times separating the code due to Undefined symbol errors and gradually everything moved into the library. Now I found rdynamic and read that windows seems to be able to do something similar as well.

Note: The plugins have to be able to call back into the core for functions like openSettings(…) and such. The design in question should run on Win/macOS/Linux.

Is this really impossible or am I doing it wrong?

Regards

1
  • 2
    Can you edit your question to include more information about the problem? I'm also struggling to understand why the library code is a problem. Can you link to something describing what rdynamic is, as well as where you read that Windows can do something similar?CommentedMay 29, 2024 at 14:27

1 Answer 1

1

The challenge with plugins are twofolds:

  • one is the application binary interface, since you need a way to dynamically link the symbols. Every OS provides some means to do that, for example windows DLLs. With C++ you have in addition name mangeling that transforms names and make them difficultly available in a symbol resolution mechanism, which forces to restrict such binding to extern "C" symbols, without the full power of C++
  • the other challenge is the interoperability, because code compiled with different versions of a C++ compiler or with different options might not be interoperable at binary level.

In this regard your library approach is not bad. It has a greater interoperability, allows more easily to share objects, and even allow for templated code to be used in the pluggin.

There are alternative approaches to ABI as well, such as launching plugin and using IPC mechanisms with a language independent protocol. Or using some controlled execution environment for a scripting language (like emacs' lisp or LUA in games). they all have pros and cons but require some overhead.

Note that plugins are a lesser problems with languages coming with a more standardized or portable execution environment (e.g. Java's JRE, or .net etc)

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.