Static plugin VS static library
-
wrote on 26 May 2011, 09:43 last edited by
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 ?
-
wrote on 26 May 2011, 09:50 last edited by
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. -
wrote on 26 May 2011, 09:57 last edited by
[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?
-
wrote on 26 May 2011, 10:14 last edited by
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.
-
wrote on 26 May 2011, 10:16 last edited by
Ok, thanks.
Now it's more clear.
1/5