Results 1 to 4 of 4

Thread: "DLL_ConfigFile_global.h"

  1. #1
    Join Date
    Mar 2012
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default "DLL_ConfigFile_global.h"

    hey there,
    I just built a dll project in QTcreator, what's weird is that if I write regular classes and i don't define DLL_CONFIGFILESHARED_EXPORT I can still use the methods of the classes of the dll in another project when i import the dll. how come?

    Qt Code:
    1. #include "DLL_ConfigFile_global.h"
    2.  
    3. class DLL_CONFIGFILESHARED_EXPORT Config{
    4.  
    5. void test();
    6. .
    7. .
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    so here, with the above code after I build the dll. I open another project I point it to this dll and the above header file and then in main I can use:
    Qt Code:
    1. Config Ctest;
    2. Ctest.test();
    To copy to clipboard, switch view to plain text mode 

    now if I remove DLL_CONFIGFILESHARED_EXPORT I can still do that, how come?

    Thank you
    Last edited by kzaarouri; 3rd March 2012 at 22:18.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: "DLL_ConfigFile_global.h"

    Some compilers/linkers/environments export everything by default or optionally (GNU tools IIRC), some don't (MSVC on Windows). Portable code uses the macros to ensure that the code works everywhere.

  3. #3
    Join Date
    Mar 2012
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: "DLL_ConfigFile_global.h"

    Hi and Thank you for your reply.
    That's good to know, now my question would then become:
    Let's say the DLL project has 3 classes:
    DLL_C1 (with methods C1_m1, C1_m2),
    DLL_C2 (with methods C2_m1, C2_m2) and
    DLL_C3 (with methods C3_m1, C3_m2)

    and let's assume that DLL_C1 cpp file includes the headers of the 2 other classes and uses them inside the definition of methods C1_m1 and C1_m2.

    Ok so now i make another project and I want to use C1_m1 and C1_m2 only from the above dll project. Should I add DLL_CONFIGFILESHARED_EXPORT
    only for the DLL_C1 class or for all the classes??

    Hope it's clear.. Thank you.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: "DLL_ConfigFile_global.h"

    I would think you need only export the C1 class unless the external user needs to know about C2/C3.

    Since you are likely using the MingW compiler in the Qt SDK this page on GCC Visibility might be of interest.

Similar Threads

  1. Replies: 1
    Last Post: 7th April 2010, 22:46
  2. Replies: 3
    Last Post: 15th February 2010, 18:27
  3. Replies: 3
    Last Post: 8th July 2008, 20:37
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 20:05
  5. QFile Problem~ "Unknow error" in "open(QIODevice::ReadWrite)"
    By fengtian.we in forum Qt Programming
    Replies: 3
    Last Post: 23rd May 2007, 16:58

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