[Qt-interest] doubt regarding creation of shared libs in QT

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Sat May 8 08:33:52 CEST 2010


>
>> Also, does this have to percolate down the inheritance hierarchy as
>> well?
>
> As for you other question, inheritance: I don't think the "exporting" is inherited. The __declspec is compiler-specific and not part of the C++ language: it simply tells the compiler "when building the object file mark this symbol as exported, so it can be linked against from a client". It does not care about OO-hierarchies.
>
> So:
>
> #include "MyLibraryDLL.h"
> #inlucde "MyLibraryClass.h"
>
> class MyExtendedLibraryClass : public MyLibraryClass {
> public:
>  MY_LIBRARY_API MyExtendedLibraryClass();
>  MY_LIBRARY_API virtual ~MyExtendedLibraryClass();
>
>  // override and export again doFoo();
>  MY_LIBRARY_API virtual void doFoo();
>
>  // add a new method and export it
>  MY_LIBRARY_API void doFooBar();
>  ...
> };
>
> That is, I would explicitly export the symbols (again). Even if you had exported the entire base class (class MY_LIBRARY_API MyLibraryClass {...};) you would still need to export the "child/specialised classes" I guess.
>
> But again, on Linux (and Mac OS X with gcc, too) Q_DECL_EXPORT renders to "nothing", AFAIK. So if you are programming some kernel module you can probably skip this entirely ;)

No LKM, mine's a simple user-space helper lib! :)

Thanks for the detailed explanation.

Will look into your code if need further help! :)

Regards,
-mandeep

>
> p.s. You can also have a look at the source code of http://www.pointshop3d.com if everything else fails, my old diploma work back in 2001 ;) It still uses Qt 3 (and was even developped with Qt 2, hence no Q_DECL_EXPORT, but __declspec(dllexport) directly), but the idea is totally the same.
>
> Cheers, Oliver
> --
> Oliver Knoll
> Dipl. Informatik-Ing. ETH
> COMIT AG - ++41 79 520 95 22
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list