PDA

View Full Version : Static vs Plugin



treyhaslem
3rd December 2009, 21:03
All,

I'm trying to get Qt to work with PostgreSQL. What is the difference between static and plugin. Also, which is the best to implement.

Trey

Tanuki-no Torigava
3rd December 2009, 22:52
I'm trying to get Qt to work with PostgreSQL. What is the difference between static and plugin. Also, which is the best to implement.


As far as I know you have 2 options:
- Use QPSQL plugin as a part of Qt or libpq.* as alternative. Qt module is not threadsafe but it is bundled so you can use it if you don't have a lot to do with Postgres.
-Use libpq (Postgres Client C library) or libpg+ (CXX wrapper over libpq). It is better choice for performance issues and multithreading. See pgadmin source code for details.

About static vs dynamic. It is not about plugin's - it is about binding of your code. It depends on what you want to do. Shared version is smaller but won't necessary work on all distro's while static is bigger but safe.

wysota
3rd December 2009, 23:19
What is the difference between static and plugin.

"Static" means support for PostgreSQL will be built into Qt library and every Qt program using the SQL module regardless if it communicates with PostgreSQL databases or not will need psql library. This is not the case with plugins. Therefore if you want to develop different kinds of applications with Qt, it's better to use the plugin approach. Just remember that if you build Qt statically, plugins will also be built statically (although not as part of Qt library) and you will have to tell your program to link against specific plugins (see docs entry for "static plugins").

Tanuki-no Torigava
3rd December 2009, 23:54
And my 5 cents. The best thing about plugins is that plugin basically represents some shared library you can load and unload. If you are working with multiple DB's and implement database interaction as a plugins - your app won't crash if some of the libraries required for you plugin not exists. But, again, default Qt plugins more a placeholders. If you need complete control and thread-safety (which is good for Postgres async transactions) - use libpq or it's C++ brother.

treyhaslem
4th December 2009, 14:04
After issuing a configure -plugin-sql-psql, do I have to do a make (mingw32-make)

calhal
4th December 2009, 14:16
After issuing a configure -plugin-sql-psql, do I have to do a make (mingw32-make)
Everytime you reconfigure the source you have to recompile. Isn't that obvious?