KDE_EXPORT in kdelibs and winposix

Ralf Habacker ralf.habacker at freenet.de
Thu Feb 9 21:16:02 CET 2006


Brad King schrieb:
> Hello,
>
> Currently KDE_EXPORT is defined both by kdemacros.h and 
> winposix_export.h.  Also, KDE_IMPORT is defined both by 
> kdelibs_export_win.h and winposix_export.h.  Their definitions are 
> different:
>
> // kdemacros.h
> #ifdef __KDE_HAVE_GCC_VISIBILITY
> #define KDE_NO_EXPORT __attribute__ ((visibility("hidden")))
> #define KDE_EXPORT __attribute__ ((visibility("default")))
> #elif defined(_WIN32) || defined(_WIN64)
> #define KDE_NO_EXPORT
> #define KDE_EXPORT __declspec(dllexport)
> #else
> #define KDE_NO_EXPORT
> #define KDE_EXPORT
> #endif
>
> // winposix_export.h
> #ifdef _MSC_VER
> #define KDE_EXPORT __declspec(dllexport)
> #define KDE_IMPORT __declspec(dllimport)
> #else
> #define KDE_EXPORT
> #define KDE_IMPORT
> #endif
>
> // kdelibs_export_win.h
> #if defined(__MINGW32__)
> # define KDE_IMPORT
> #else
> # define KDE_IMPORT __declspec(dllimport)
> #endif
>
> This results in a redefinition of KDE_EXPORT for many translation units 
> on Windows.  Many DLL linking problems result when I try to build 
> kdelibs, particularly on MinGW.
>
> I suggest that the winposix_export.h versions be renamed to 
> WINPOSX_EXPORT and WINPOSX_IMPORT since they are supposed to be 
> separated from kdelibs anyway.  They are only used for symbols in 
> kdewin32 so this should be okay: KDEWIN32_EXPORT would map to 
> WINPOSX_EXPORT or WINPOSX_IMPORT depending on whether the library is 
> being built or used.
>
>   
I agree
> I also propose removing KDEWIN32_EXPORT from kdelibs_export_win.h 
> because it should be defined only in winposix_export.h.  Since 
> winposix_export.h is included directly or indirectly by all headers in 
> kdewin32 this should work well.
>
> The file win/include/mingw/sys/types.h does this:
>
> #ifdef __cplusplus
> #include <winposix_export.h>
> #else
> #define KDEWIN32_EXPORT
> #endif
>
> but it looks like it should just be
>
> #include <winposix_export.h>
>   
The above construct was initial to prevents including qt headers for 
compiling c code through kdelibs_export.h. If similar support is 
required in the future, we can add this to winposix_export.h

> Finally, I think __declspec(dllimport) should be used on MinGW just like 
> other windows platforms.  The auto-import feature does not work well for 
> data symbols such as vtables.  See the man-page of ld in MinGW or cygwin 
> and read the enable-auto-import flag documentation for details.
>   
For this the option `--enable-runtime-pseudo-relocs' was added, see 
http://sourceware.org/binutils/docs-2.16/ld/WIN32.html.
For cygwin's kde3 release I had used this to build many KDE packages 
without required dllspec decoration, which was the default in KDE 3.
In fact without this support KDE3 on cygwin would not have been able. 
But now because we have complete EXPORT decorations, this support isn't 
required.

> Comments?
>
>   
There are some KDE_EXPORT references in kdelibs_export_win.h. May be 
they could be moved into kdelibs_export.h to have all definitions in one 
place. Can anyone say if there any problems to expect ?

BTW: I've tried to link the libkdewin32.dll. Can you say how to create 
the relating import library with cmake using ld -Wl,-out-implib option ?

Ralf



More information about the Kde-buildsystem mailing list