Results 1 to 10 of 10

Thread: How to use a class who has SHAREDEXPORT in 'direct' mode?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to use a class who has SHAREDEXPORT in 'direct' mode?

    I explain it.
    I have a class part of mydll (it works ok)
    ok, I want to use the .h and .cpp files of this class individually in 'pure' or 'direct' way , but I have two elements that are the guilty it does not work :
    1.- The .h file has an include to global.h (where I define the SHARED_EXPORT sufix)
    Qt Code:
    1. #include <QtCore/qglobal.h>
    2. #define ACLASSSHARED_EXPORT Q_DECL_EXPORT
    3. etc
    To copy to clipboard, switch view to plain text mode 
    2.- The class it self (.h) that has 'ACLASSSHARED_EXPORT Aclass' name .

    When I wnat to use in my project I have several errors an undefined references.
    If I want top use it I have to duplicate the files and to delete the #include global.h and the 'ACLASSSHARED_EXPORT' sufix.

    Is there a way to avoid this ?
    Can I use a qmake variable to say 'If you are in dll environmet use it' if not, dont.
    (or something like this?)
    Thanks (I hope you can understand what I want)

  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: How to use a class who has SHAREDEXPORT in 'direct' mode?

    can you post the full export defines of ACLASSSHARED_EXPORT?
    You should have an #ifdef statement there, that changes the export to import depending if you are building the DLL or linking against it.
    It seems this is not quite correct in your case.
    ==========================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
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    This is the code for acore_global.h

    Qt Code:
    1. #ifndef ACORE_GLOBAL_H
    2. #define ACORE_GLOBAL_H
    3. #include <QtCore/qglobal.h>
    4. #if defined(ACORE_LIBRARY)
    5. # define W_FILESSSHARED_EXPORT Q_DECL_EXPORT
    6. # define W_UTILESSHARED_EXPORT Q_DECL_EXPORT
    7. # define W_QTUTILSHARED_EXPORT Q_DECL_EXPORT
    8. # define W_ASCIISHARED_EXPORT Q_DECL_EXPORT
    9. # define W_XMLSHARED_EXPORT Q_DECL_EXPORT
    10. # define W_CONFIGSHARED_EXPORT Q_DECL_EXPORT
    11. #else
    12. # define W_FILESSSHARED_EXPORT Q_DECL_IMPORT
    13. # define W_UTILESSHARED_EXPORT Q_DECL_IMPORT
    14. # define W_QTUTILSHARED_EXPORT Q_DECL_IMPORT
    15. # define W_ASCIISHARED_EXPORT Q_DECL_IMPORT
    16. # define W_XMLSHARED_EXPORT Q_DECL_IMPORT
    17. # define W_CONFIGSHARED_EXPORT Q_DECL_IMPORT
    18. #endif
    19.  
    20. #endif // ACORE_GLOBAL_H
    To copy to clipboard, switch view to plain text mode 


    and filess.h is

    Qt Code:
    1. #ifndef W_FILESS_H
    2. #define W_FILESS_H
    3.  
    4. #include "Acore_global.h"
    5. class W_FILESSSHARED_EXPORT W_filess
    6. {
    To copy to clipboard, switch view to plain text mode 

    This is a piece of my dll that works fine.
    How can I use filess.h in another project but not in dll ? (That is, just including the files with #include)
    . Have I to write another thing at Acore_global.h ?
    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    Change the file containing the macro definitions so that if a particular macro is defined (or not), W_FILESSHARED_EXPORT expands to nothing.

    BTW. Moving to General Programming, this has nothing to do with Qt. Next time please think which forum is the best to post a particular question.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    Thanks Wysota but ... How I do that ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    The same way you did with ACORE_LIBRARY.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    Thanks
    I'm going to re-read the Qt help regarding this.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    Qt help has nothing to do with this. This is strictly a C++ (or even cpp) issue. You know how #ifdef and #define work, right?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    Thanks Wy.
    Ok, it works with :
    Qt Code:
    1. #ifndef ACORE_GLOBAL_H
    2. #define ACORE_GLOBAL_H
    3.  
    4. #include <QtCore/qglobal.h>
    5.  
    6. #if defined(ACORE_LIBRARY)
    7. # define W_FILESSSHARED_EXPORT Q_DECL_EXPORT
    8. # define W_UTILESSHARED_EXPORT Q_DECL_EXPORT
    9. # define W_QTUTILSHARED_EXPORT Q_DECL_EXPORT
    10. # define W_ASCIISHARED_EXPORT Q_DECL_EXPORT
    11. # define W_XMLSHARED_EXPORT Q_DECL_EXPORT
    12. # define W_CONFIGSHARED_EXPORT Q_DECL_EXPORT
    13. #else
    14. #if defined(ACORE_DIRECT)
    15. # define W_FILESSSHARED_EXPORT
    16. # define W_UTILESSHARED_EXPORT
    17. # define W_QTUTILSHARED_EXPORT
    18. # define W_ASCIISHARED_EXPORT
    19. # define W_XMLSHARED_EXPORT
    20. # define W_CONFIGSHARED_EXPORT
    21. #else
    22. # define W_FILESSSHARED_EXPORT Q_DECL_IMPORT
    23. # define W_UTILESSHARED_EXPORT Q_DECL_IMPORT
    24. # define W_QTUTILSHARED_EXPORT Q_DECL_IMPORT
    25. # define W_ASCIISHARED_EXPORT Q_DECL_IMPORT
    26. # define W_XMLSHARED_EXPORT Q_DECL_IMPORT
    27. # define W_CONFIGSHARED_EXPORT Q_DECL_IMPORT
    28. #endif
    29. #endif
    30. #endif // ACORE_GLOBAL_H
    To copy to clipboard, switch view to plain text mode 

    And DEFINES +=ACORE_DIRECT in the .pro file.
    Thanks.
    A last question :
    I use in my .pro:
    INCLUDEPATH += mypath
    DEPENDPATH += mypath
    So, I can write code and QTknows where the class I'm using are, but it does not compile.
    (Only compile if I add the files for the class to my project)
    What more I need?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to use a class who has SHAREDEXPORT in 'direct' mode?

    You need to tell your compiler you wish to have those classes compiled or linked into you project.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 27th May 2010, 15:18
  2. Signal/slot or direct method call within a class
    By mike_the_tv in forum Newbie
    Replies: 6
    Last Post: 11th March 2010, 18:49
  3. Replies: 1
    Last Post: 2nd November 2009, 12:02
  4. Replies: 9
    Last Post: 15th April 2009, 06:23
  5. Replies: 8
    Last Post: 10th October 2007, 18:20

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.