Results 1 to 6 of 6

Thread: Extending a plugin in a static library

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Extending a plugin in a static library

    • 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 :

    Qt Code:
    1. 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 :

    Qt Code:
    1. exists( $$[QT_INSTALL_PLUGINS]/sqldrivers/libqsqlpsql* ) {
    2. # plugin found do tricky linking
    3. LIBS += -L$$[QT_INSTALL_PLUGINS]/sqldrivers -lqsqlpsql
    4. } else {
    5. # plugin not found, QT += sql should do
    6. # unless of course the psql plugin is simply not built at all
    7. }
    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.
    Last edited by fullmetalcoder; 4th March 2009 at 19:12.
    Current Qt projects : QCodeEdit, RotiDeCode

Similar Threads

  1. How to use static mysql plugin
    By khikho in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2009, 21:44
  2. Compiling QCA as static library
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2008, 17:32
  3. plugin in a library
    By alisami in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2008, 17:21
  4. Replies: 16
    Last Post: 23rd May 2008, 10:12
  5. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.