Results 1 to 6 of 6

Thread: Use external DLL ?

  1. #1
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Use external DLL ?

    Hi,

    I have a project that I build with QTCreator 2.1 beta. I have a PureLight.DLL file for the first project where I declare my methods like this

    __attribute__((dllexport)) int plGetError();
    In another application, I would like to use this DLL, and so I use the following code:

    __attribute__((dllimport)) int plGetError();
    But when I build my application it gives me this error message :
    undefined reference to '_imp_plGetError'
    What does it mean, do you have an idea ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Use external DLL ?

    Did you include the header file that defines plGerError()?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use external DLL ?

    Of course, it sounds that it is a "link" error and not a "compilation" error

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Use external DLL ?

    Indeed it does, did you link with the appropriate .lib file?

  5. #5
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use external DLL ?

    I need a ".lib" file to link to a DLL ? Is it really necessary ?

    It is a DLL... so it should discover methods at run time ?

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Use external DLL ?

    Your DLL knows about its symbols, but the outer world does not, the lib file has information about the symbols inside the DLL.
    You don't actually need the lib, but its much more complected to do with out a lib file.
    You can use delayed dll loading and than use GetProcAddress() and manually based on the header create the pointers to the function in the DLL.
    You might need that if you don't have a lib file to an external DLL - but you do have the header (you need to know the constructs of the functions - an export file can also be used). or if you wish not to distribute your lib file for what ever reason.
    Based on your questions, you should probably first practice in building and using DLLs the "normal" way - and read about what linking is and how it works.
    Some useful links:
    http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
    http://msdn.microsoft.com/en-us/library/151kt790.aspx
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. adding external .lib
    By sqvarek in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2011, 04:54
  2. Using external libraries
    By Handi in forum Newbie
    Replies: 5
    Last Post: 9th December 2010, 22:51
  3. Qt & External Threaded API
    By mreyfout in forum Qt Programming
    Replies: 0
    Last Post: 28th October 2010, 22:39
  4. add external api
    By adamatic in forum Qt Programming
    Replies: 6
    Last Post: 16th April 2009, 10:25
  5. Close an external GUI
    By thebra in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 22:53

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.