Results 1 to 4 of 4

Thread: passing object to plugin

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Posts
    79
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: passing object to plugin

    the code compiles without problem, as you can see it is linker error;
    and plugin implementation file include header declaring Conf.h

    I can define
    void Lib1::init(QObject * ptr)
    as
    void Lib1::init(Conf * ptr)

    but it still say "undefined reference to `Conf::getValue(int)'"

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    315
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: passing object to plugin

    You have an undefined reference because even though your plugin knows what a Conf class looks like (which means it can compile the code), it doesn't have any idea how to get the Conf instance to do anything, because you haven't linked in the object code that contains the Conf class implementation.

    This is exactly what Chris was saying in his answer. Both the application and the plugin need to be linked against the Conf class object code if they need to use the objects. If all your plugin does is pass around pointers to Conf instances but never tries to call any Conf class methods, then you simply need the header file so it can be compiled. But it looks like you expect your plugins to be able to use the Conf pointers, so you will need all of then to link against the object code.

    Either that, or put the Conf object code in a DLL and link all of your apps and plugins against that so you aren't duplicating code.

  3. The following user says thank you to d_stranz for this useful post:

    folibis (18th November 2011)

Similar Threads

  1. Passing an object from one form to the other.
    By cbarmpar in forum Qt Programming
    Replies: 10
    Last Post: 3rd September 2008, 14:12
  2. Replies: 4
    Last Post: 12th August 2008, 01:55
  3. passing an object
    By mickey in forum General Programming
    Replies: 3
    Last Post: 16th January 2008, 10:27
  4. Passing Object to dll
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 09:50
  5. passing a QPainter object to widgets
    By vratojr in forum Qt Programming
    Replies: 9
    Last Post: 11th January 2006, 15:27

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.