Static plugin VS static library
-
Hi all,
these days I'm doing some tests with Qt Plugin but I didn't understand very well how it works.I'm checking the "Plug & Paint" example. This example use static and dynamic plugin .
When I use shared or static library in my Qt project I don't need to use QPluginLoader .
For example to use QExtSerialPort I only need to add to my .pro :
@
INCLUDEPATH += ../qextserialport_x86
QMAKE_LIBDIR += ../qextserialport_x86/build
LIBS += -lqextserialport
DEFINES = TTY_POSIX
@But what are the main differences between static plugin and static library ?
-
Short story: a plugin is a library with a predefined interface, be static or shared doesn't matter.
EDIT:
Oh, and plugins are usually not needed to fire up an application, as they are usually loaded by the app itself. Whereas regular (shared) libraries are needed to run the app, because they are loaded by the operating system. Missing a library causes the operating system to bail out with - hopefully - an error message. -
[quote author="Volker" date="1306403458"]Short story: a plugin is a library with a predefined interface, be static or shared doesn't matter.
EDIT:
Oh, and plugins are usually not needed to fire up an application, as they are usually loaded by the app itself. Whereas regular (shared) libraries are needed to run the app, because they are loaded by the operating system. Missing a library causes the operating system to bail out with - hopefully - an error message.[/quote]Thanks Volker.
Does a static plugin is required to start an application? If yes it's the same of a library.What is the main reasons because of QExtSerialPort is a library and not a plugin. Shouldn't it be better as a plugin?
-
A static plugin is compiled into the exe. Otherwise it would not be static :-)
A plugin is optional, a library is required (shortened view, one could construct examples where it is the other way round)
See it like the SQL support in Qt:
- QtSql4.dll is the libraray, it provides the core functionality
- libqsqlite.dll, libsqsqlmysql.dll are the drivers and work as plugins
This way you can easily write your own SQL driver and don't need to relink your application or recompile the QtSql lib.