PDA

View Full Version : Developing Plugins



Jimmy2775
28th February 2007, 17:53
I have a couple of questions regarding Qt plugin development.

1. Reading Qt's documentation of "How to Create Qt Plugins", the section describing the build key notes that "In cases where different versions of the same compiler do not produce binary compatible code, the version of the compiler is also present in the build key". Does anyone know how I can determine if different versions of compilers produce binary compatible code? I am by no means a C++ expert so I'm not exactly certain what this means even. I have written some Qt code compiled with MSVC 7 - will I be able to plugin components compiled with MSVC 8? What about other compilers?

2. When defining an interface, the Q_DECLARE_INTERFACE() macro associates an identifier with an interface class name. In the Qt examples it seems that they include a version number in the identifier (e.g. "com.trolltech.PlugAndPaint.BrushInterface/1.0"). Is this version number used anywhere by Qt? If Qt finds two different versions of the same plugin, I would like to use the newer one, but I'm not sure if this is something Qt does automatically or if that's a behavour I have to code myself.

Thank you.

fullmetalcoder
28th February 2007, 18:13
The build key is rarely a problem. Indeed if you distribute the source of your application, users are always able to compile both application and plugins without compatibility problems. Just the same way, if you distribute only binaries (as your use of MSVC might suggest), they will be compiled on your box and plugins and app will always have the same build key...:)
AFAIK the plugin identifiers are not interpreted by Qt plugin loading code in any special way because its only purpose is to ensure the unicity of interfaces... Thus the version match must be done by hand... BTW I'm not even sure that the identifier can be retrieved at run time. Besides identifier are set for an interface not for an implementation and if the interface change the identifier should change as well because backward compatibility will be lost...

Methedrine
28th February 2007, 18:14
I have a couple of questions regarding Qt plugin development.

1. Reading Qt's documentation of "How to Create Qt Plugins", the section describing the build key notes that "In cases where different versions of the same compiler do not produce binary compatible code, the version of the compiler is also present in the build key". Does anyone know how I can determine if different versions of compilers produce binary compatible code? I am by no means a C++ expert so I'm not exactly certain what this means even. I have written some Qt code compiled with MSVC 7 - will I be able to plugin components compiled with MSVC 8? What about other compilers?


I would not worry too much about the buildkey. For example I was able to load a plugin built with gcc from an executable built with MSVC 8.



2. When defining an interface, the Q_DECLARE_INTERFACE() macro associates an identifier with an interface class name. In the Qt examples it seems that they include a version number in the identifier (e.g. "com.trolltech.PlugAndPaint.BrushInterface/1.0"). Is this version number used anywhere by Qt? If Qt finds two different versions of the same plugin, I would like to use the newer one, but I'm not sure if this is something Qt does automatically or if that's a behavour I have to code myself.

Thank you.

The identifier is used for deciding whether a plugin can be loaded or not. AFAIK there's no option for you to decide which version to load, Qt simply requires that the identifiers match.

Jimmy2775
28th February 2007, 18:47
Just the same way, if you distribute only binaries (as your use of MSVC might suggest), they will be compiled on your box and plugins and app will always have the same build key...:)

Thanks for the info. My concern is with the fact that the app will be compiled on my machine, but it is possible for third-party developers to compile their own plugins for the app. I am trying to determine how much if a problem this could be if they're using a different compiler. Ideally I'd like to be able to provide documentation listing which compilers they could use to create compatible plugins. Is this something that is known, or do I have to try different compilers and see what works and what doesn't?

fullmetalcoder
28th February 2007, 18:57
Thanks for the info. My concern is with the fact that the app will be compiled on my machine, but it is possible for third-party developers to compile their own plugins for the app. I am trying to determine how much if a problem this could be if they're using a different compiler. Ideally I'd like to be able to provide documentation listing which compilers they could use to create compatible plugins. Is this something that is known, or do I have to try different compilers and see what works and what doesn't?
Well basically the build platform already brings restriction and I think that, except some exceptions, binaries build on the same platform should be compatible especially if the use of external libraries (apart from Qt) is reduced...

See :

For example I was able to load a plugin built with gcc from an executable built with MSVC 8.
:D

Jimmy2775
28th February 2007, 19:03
Okay - I guess that makes sense. Let's see if I understand this right - If all my Windows code is compiled with MSVC8, most other Windows compilers should be able to compile compatible plugins, and likewise if I use Intel's C++ compiler for Mac, most other Mac compilers should create compatible plugins. If that's the case then that's good enough for me.

Thanks fullmetalcoder and Methedrine for your help.

Jimmy