[Qt-interest] dll problem

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Dec 11 11:00:04 CET 2008


Evan Teran wrote on Monday, December 08, 2008 9:15 PM:

> Actually, my problem isn't lack of compilation. It's runtime crashes
> that don't occur on my linux builds.
>
> I actually need to do the opposite of your suggestion to, because
> some of my plugins use objects which are provided by my core
> application.

That's "broken by design", also on Linux (in fact, this broken design has nothing to do with any OS, is a "platform-independent broken-by-design" :)

A plugin mustn't access symbols from the main application (executable), because an executable is - guess what - not a shared library!

So what you really need is a design with a clean dependency tree (no mutual dependencies!).

As already suggested several times you'd put the main functionallity of your application into a DLL/shared object and *export* the symbols you need in the above layers (plugins or other application libraries): for Windows google for (__declspec dllimport/dllexport), read the MSDN and/or create a sample DLL within Visual Studio. For reference you could also have a look at http://www.pointshop3d.com. It is based on Qt 2.x and I wrote a "plugin loader" myself (which basically did what QPluginLoader/QLibrary do nowadays) - but nevertheless you'll quickly see the DLL dependencies.

The main application then merely consists of a simple main() function which instantiates the QApplication object and pulls in all the application DLLs

> If i do have the noundef stuff in there (i ran into an
> issue where ubuntu was adding it to the defaul flags on lib builds).
> Then I get linker errors on Linux.

As expected - you can't export symbols/functions from an executable!

> Which isn't what I want :(.

Right ;)

> Likewise on windows builds I have to add /FORCE to the compiler flags
> for plugins to let the linker not care about missing symbols since
> they will be provided by the main app.

Broken by design, see above.

Cheers, Oliver




More information about the Qt-interest-old mailing list