Results 1 to 4 of 4

Thread: Problem with class-function from dll

  1. #1

    Default Problem with class-function from dll

    Good Morning,

    I created a .dll with Qt-creator 5.4, that is exporting some classes.
    I now want to use these classes in an other Qt-Project. I managed to create an instance of the classes, but when i try to use a function (of course a public one) from one of the classes, i get an Error "undefined reference to ..."

    Perhaps i make some very stupid errors, because its my first time working with a .dll

    Can Anybody please help?

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Problem with class-function from dll

    Can you show the actual error and the relevant sections of the classes you are exporting?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problem with class-function from dll

    "undefined reference to ..."
    Are you linking to the .lib that gets created along with the .dll? Did you declare the classes you want to export with __declspec( dllexport ) when you built the DLL, and do you declare them with __declspec( dllimport ) when you want to use them in your EXE?

  4. #4

    Default Re: Problem with class-function from dll

    I am linking to the .a file that was created with the .dll, i found that it is the same as the .lib file when i searched google.
    And i am using the Qt-Macro Q_DECL_EXPORT to export and the Qt-Macro Q_DECL_IMPORT to import (just because the Qt-Creator gave it to me when i made a library-project).
    I can try to use __declspec( dllexport ) and __declspec( dllimport ), but i think it does the same as the Qt-Macros.

    The code looks like this in my exported classes:
    Qt Code:
    1. class Q_DECL_EXPORT test1
    2. {
    3. public:
    4. test1();
    5. int func1();
    6. void func2();
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 


    EDIT: Thank you guys for your help, i solved the Problem now
    There was a problem with the make-file i think, because i set a complet new project wit hexactly the same code and now it works, i can use the functions from the exported classes
    Last edited by Ragnar; 16th July 2015 at 12:20.

Similar Threads

  1. Replies: 11
    Last Post: 5th September 2012, 20:47
  2. Replies: 4
    Last Post: 23rd August 2011, 21:53
  3. Replies: 7
    Last Post: 2nd September 2010, 19:42
  4. Problem with the put() function of QFtp class
    By whyisosad in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 10:03
  5. Replies: 3
    Last Post: 16th May 2007, 11:07

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.