PDA

View Full Version : Qt plugins in simple C++



LMZ
10th June 2007, 15:25
It is possible to load Qt plugin (dll/so, written myself) in a simple C++ program (not Qt)?

Jeroen van der Waal
10th June 2007, 18:21
Hi,

I guess this will be difficult.

For example QObject is inherited by a plugin. Also the interface of the plugin is described in QT types. All the types QObject / the interface types are not known when you are using the plugin without qt. This makes it almost impossible to use the plugin.

Methedrine
10th June 2007, 21:18
I don't think it can easily be achieved, if at all. However, you'd just need to link to QtCore to use Qt's plugin-system.

wysota
11th June 2007, 09:14
The real question is - what for? You can create your own plugin architecture - just make a library of symbols and make sure it exports a function with a known name. Then dlopen and dlsym that function in your application. It should be a factory function for your interface implementation.

LMZ
11th June 2007, 18:04
2 wysota
"You can create your own plugin architecture"
with Qt, yes?
be please more detailed
2 Methedrine
I didn't think about it, thanks!

wysota
11th June 2007, 18:52
"You can create your own plugin architecture"
with Qt, yes?
No, with C/C++. Qt doesn't have anything to do with it.


be please more detailed

Please be more detailed about what more details you want. For starters, read about dlopen and dlsym. If you need that under Windows, there are equivalent functions for it.

LMZ
12th June 2007, 10:34
"No, with C/C++. Qt doesn't have anything to do with it." ok, I understood, thanks.
One more little question, what soft (under Linux) can show contents of the Static Library (.so) function/classes?

wysota
12th June 2007, 11:33
Files with "so" extension are not static libraries, they are shared objects. You can feed such an object to "nm" and it'll return a list of symbols the library contains. Note that the list will contain mangled names!

stevey
14th June 2007, 05:52
Here's a nice plugin system example in plain C++.
I believe it uses windows sdk specific stuff, but I'm sure it could be made cross platform with a few #ifdef's / factories.

http://www.nuclex.org/articles/building-a-better-plugin-architecture