diff --git a/setupext.py b/setupext.py index 2eed52514040..58512a5d0581 100644 --- a/setupext.py +++ b/setupext.py @@ -396,8 +396,8 @@ def get_extensions(self): include_dirs=["src"], # psapi library needed for finding Tcl/Tk at run time. # user32 library needed for window manipulation functions. - libraries=({"linux": ["dl"], "win32": ["psapi", "user32"]} - .get(sys.platform, [])), + libraries=({"linux": ["dl"], "win32": ["psapi", "user32"], + "cygwin": ["psapi"]}.get(sys.platform, [])), extra_link_args={"win32": ["-mwindows"]}.get(sys.platform, [])) add_numpy_flags(ext) add_libagg_flags(ext) diff --git a/src/_tkagg.cpp b/src/_tkagg.cpp index 9a03aed82331..eb2b172b115c 100644 --- a/src/_tkagg.cpp +++ b/src/_tkagg.cpp @@ -11,6 +11,20 @@ #include #ifdef _WIN32 +#define WIN32_DLL +#endif +#ifdef __CYGWIN__ +/* + * Unfortunately cygwin's libdl inherits restrictions from the underlying + * Windows OS, at least currently. Therefore, a symbol may be loaded from a + * module by dlsym() only if it is really located in the given modile, + * dependencies are not included. So we have to use native WinAPI on Cygwin + * also. + */ +#define WIN32_DLL +#endif + +#ifdef WIN32_DLL #include #define PSAPI_VERSION 1 #include // Must be linked with 'psapi' library @@ -122,7 +136,7 @@ int load_tk(T lib) (Tk_PhotoPutBlock_NoComposite_t)dlsym(lib, "Tk_PhotoPutBlock_NoComposite")); } -#ifdef _WIN32 +#ifdef WIN32_DLL /* * On Windows, we can't load the tkinter module to get the Tk symbols, because