diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd8d68876..1befff42a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2212,6 +2212,10 @@ if(SDL_SHARED)
SOVERSION ${LT_REVISION}
OUTPUT_NAME "SDL2-${LT_RELEASE}")
else()
+ if(WINDOWS OR CYGWIN)
+ set_target_properties(SDL2 PROPERTIES
+ DEFINE_SYMBOL DLL_EXPORT)
+ endif()
set_target_properties(SDL2 PROPERTIES
VERSION ${SDL_VERSION}
SOVERSION ${LT_REVISION}
diff --git a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
index b04b048fc..b55e49e19 100644
--- a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
+++ b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
@@ -508,7 +508,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -522,7 +522,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -536,7 +536,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -550,7 +550,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -564,7 +564,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -578,7 +578,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
index 563dcbe25..b36d4f111 100644
--- a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
+++ b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
@@ -425,7 +425,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -439,7 +439,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -453,7 +453,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -467,7 +467,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
index a17157ca9..39e791ad3 100644
--- a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
+++ b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
@@ -504,7 +504,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -519,7 +519,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -534,7 +534,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -549,7 +549,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -564,7 +564,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
@@ -579,7 +579,7 @@
NotUsing
false
..\..\include;%(AdditionalIncludeDirectories)
- _WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
+ DLL_EXPORT;_WINDLL;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions)
Console
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index e592e94e3..0e8b293f6 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -96,7 +96,7 @@
Disabled
$(ProjectDir)/../../include;%(AdditionalIncludeDirectories)
%(AdditionalUsingDirectories)
- _DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ DLL_EXPORT;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDLL
false
StreamingSIMDExtensions
@@ -127,7 +127,7 @@
Disabled
$(ProjectDir)/../../include;%(AdditionalIncludeDirectories)
%(AdditionalUsingDirectories)
- _DEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ DLL_EXPORT;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDLL
false
Level3
@@ -160,7 +160,7 @@
$(ProjectDir)/../../include;%(AdditionalIncludeDirectories)
%(AdditionalUsingDirectories)
- NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ DLL_EXPORT;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDLL
false
StreamingSIMDExtensions
@@ -192,7 +192,7 @@
$(ProjectDir)/../../include;%(AdditionalIncludeDirectories)
%(AdditionalUsingDirectories)
- NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
+ DLL_EXPORT;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)
MultiThreadedDLL
false
Level3
diff --git a/include/begin_code.h b/include/begin_code.h
index 1eb2f9cc2..1ca40ccdb 100644
--- a/include/begin_code.h
+++ b/include/begin_code.h
@@ -51,14 +51,8 @@
/* Some compilers use a special export keyword */
#ifndef DECLSPEC
-# if defined(__WIN32__) || defined(__WINRT__)
-# ifdef __BORLANDC__
-# ifdef BUILD_SDL
-# define DECLSPEC
-# else
-# define DECLSPEC __declspec(dllimport)
-# endif
-# elif defined(_DLL)
+# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__)
+# ifdef DLL_EXPORT
# define DECLSPEC __declspec(dllexport)
# else
# define DECLSPEC