- How do I load the qsqlpsql plugin successfully?
- Do I load the plugin in the library the defines the derived class? Or the application that uses my library?
It's not "loading" that is required here (which refers to a run-tile action) but linking against the plugin (which is a shared lib but not one of the "regular" Qt libs you are used to linkin against).
When the "base" plugin is built as a "real" plugin (not embedded in QtSql lib but placed in its own shared lib) linking gets WAY trickier. You got to figure out where plugins are located, what is the actual name of the plugin and you have to adjust the LIBS veriable accordingly as follows :
LIBS += -L$$[QT_INSTALL_PLUGINS]/sqldrivers -lqsqlpsql
LIBS += -L$$[QT_INSTALL_PLUGINS]/sqldrivers -lqsqlpsql
To copy to clipboard, switch view to plain text mode
Please note that I haven't tested this trick but it should work with a vanilla Qt install if qsql_psql plugin is available.
A somewhat "safer", though more restrictive way to do what you want is to compile Qt in static mode and to use static plugins.
- Is there a way to make it "just work" transparently no matter if I build QT with the qsql_psql as a plugin or a library?
You'll need some dark qmake magic to figure whether the sql plugin exists as a plugin but it is doable :
exists( $$[QT_INSTALL_PLUGINS]/sqldrivers/libqsqlpsql* ) {
# plugin found do tricky linking
LIBS += -L$$[QT_INSTALL_PLUGINS]/sqldrivers -lqsqlpsql
} else {
# plugin not found, QT += sql should do
# unless of course the psql plugin is simply not built at all
}
exists( $$[QT_INSTALL_PLUGINS]/sqldrivers/libqsqlpsql* ) {
# plugin found do tricky linking
LIBS += -L$$[QT_INSTALL_PLUGINS]/sqldrivers -lqsqlpsql
} else {
# plugin not found, QT += sql should do
# unless of course the psql plugin is simply not built at all
}
To copy to clipboard, switch view to plain text mode
- Does my scheme (deriving off of a plugin and putting that derived class in a library) even work when using the plugin architecture?
As long as the class you want to subclass is exported (only matters under Win though, AFAIK) by the shared library, linking will work so your scheme should work.
Bookmarks