PDA

View Full Version : "DLL_ConfigFile_global.h"



kzaarouri
3rd March 2012, 22:14
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?



#include "DLL_ConfigFile_global.h"

class DLL_CONFIGFILESHARED_EXPORT Config{

void test();
.
.

}


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:


Config Ctest;
Ctest.test();


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

Thank you

ChrisW67
4th March 2012, 00:51
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.

kzaarouri
4th March 2012, 01:52
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.

ChrisW67
4th March 2012, 03:43
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 (http://gcc.gnu.org/wiki/Visibility) might be of interest.