diff --git a/interpreter/cling/lib/Interpreter/CIFactory.cpp b/interpreter/cling/lib/Interpreter/CIFactory.cpp
index 8c4de134286958e5e168a8bd9291e9efdb08bfc4..742eddd53739155a5d409bf9c5367610d5f40497 100644
--- a/interpreter/cling/lib/Interpreter/CIFactory.cpp
+++ b/interpreter/cling/lib/Interpreter/CIFactory.cpp
@@ -516,6 +516,12 @@ std::string stringifyPreprocSetting(const char* name, int val) {
     PPOpts.addMacroDef("_GLIBCXX_USE_CXX11_ABI="
                        ClingStringify(_GLIBCXX_USE_CXX11_ABI));
 #endif
+
+#if defined(LLVM_ON_WIN32)
+    PPOpts.addMacroDef("CLING_EXPORT=__declspec(dllimport)");
+#else
+    PPOpts.addMacroDef("CLING_EXPORT=");
+#endif
   }
 
   /// Set target-specific preprocessor defines.
diff --git a/interpreter/cling/test/CodeGeneration/Symbols.C b/interpreter/cling/test/CodeGeneration/Symbols.C
index 77da0b6287a4636da175323a66ce7cdcfb12f99e..d923342b49832944c41e6984da989f43b869d43c 100644
--- a/interpreter/cling/test/CodeGeneration/Symbols.C
+++ b/interpreter/cling/test/CodeGeneration/Symbols.C
@@ -6,23 +6,20 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: clang -shared -fPIC -DBUILD_SHARED %s -o%T/libSymbols%shlibext
+// RUN: clang -shared -fPIC -DCLING_EXPORT=%dllexport -DBUILD_SHARED %s -o%T/libSymbols%shlibext
 // RUN: %cling --nologo -L%T -lSymbols  %s | FileCheck %s
-// This won't work on Windows as the weak symbol's address is not uniqued
-// across DLL boundaries.
-// REQUIRES: not_system-windows
 
 // Check that weak symbols do not get re-emitted (ROOT-6124)
 extern "C" int printf(const char*,...);
 
 template <class T>
-struct StaticStuff {
+struct CLING_EXPORT StaticStuff {
   static T s_data;
 };
 template <class T>
 T StaticStuff<T>::s_data = 42;
 
-int compareAddr(int* interp);
+CLING_EXPORT int compareAddr(int* interp);
 #ifdef BUILD_SHARED
 int compareAddr(int* interp) {
   if (interp != &StaticStuff<int>::s_data) {
diff --git a/interpreter/cling/test/Interfaces/address.C b/interpreter/cling/test/Interfaces/address.C
index 904f9e913c4ba8ef983592b307fe2ba652ef4721..a81653587d54ca5e3bd40cd914d31bd41e0696fb 100644
--- a/interpreter/cling/test/Interfaces/address.C
+++ b/interpreter/cling/test/Interfaces/address.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: clang -shared %S/address_lib.c -olibaddress_lib%shlibext
+// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/address_lib.c -olibaddress_lib%shlibext
 // RUN: cat %s | %built_cling -L. -fno-rtti | FileCheck %s
 extern "C" int printf(const char*,...);
 
diff --git a/interpreter/cling/test/Interfaces/address_lib.c b/interpreter/cling/test/Interfaces/address_lib.c
index 35220df3dfc7df78af86c52660fdaf53ffac5f79..cb5cc8723465f941903274090c303139cfb6b37c 100644
--- a/interpreter/cling/test/Interfaces/address_lib.c
+++ b/interpreter/cling/test/Interfaces/address_lib.c
@@ -8,7 +8,8 @@
 
 // RUN: true
 // Used as library source by address.C
-int gLibGlobal = 14;
+
+CLING_EXPORT int gLibGlobal = 14;
 
 #pragma pack(1)
-const char gByteAlign0 = 0, gByteAlign1 = 1, gByteAlign2 = 2, gByteAlign3 = 3;
+CLING_EXPORT const char gByteAlign0 = 0, gByteAlign1 = 1, gByteAlign2 = 2, gByteAlign3 = 3;
diff --git a/interpreter/cling/test/LibraryCall/call.C b/interpreter/cling/test/LibraryCall/call.C
index e2a568b16047dc06da75a808c5485ae77a8ed51f..c01442b506667f0475286efdc94d10ce78161d61 100644
--- a/interpreter/cling/test/LibraryCall/call.C
+++ b/interpreter/cling/test/LibraryCall/call.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: clang -shared %S/call_lib.c -o%T/libcall_lib2%shlibext
+// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib2%shlibext
 // RUN: cat %s | %cling -L%T | FileCheck %s
 
 .L libcall_lib2
diff --git a/interpreter/cling/test/LibraryCall/call_lib.c b/interpreter/cling/test/LibraryCall/call_lib.c
index a51edc25cd6b7bbcb2898140c00c85667cf667e4..4cd6ea5fbb9691b3152b9b2cec10177b0adb4dd8 100644
--- a/interpreter/cling/test/LibraryCall/call_lib.c
+++ b/interpreter/cling/test/LibraryCall/call_lib.c
@@ -8,6 +8,6 @@
 
 // RUN: true
 // Used as library source by call.c
-int cling_testlibrary_function() {
+CLING_EXPORT int cling_testlibrary_function() {
   return 0x42;
 }
diff --git a/interpreter/cling/test/LibraryCall/callable_lib.C b/interpreter/cling/test/LibraryCall/callable_lib.C
index 8ff46729c21af9b2fafbed7cf61f6c66cf74e880..72a6bb16504dbe66ae5e295c286c1b50dc38fb17 100644
--- a/interpreter/cling/test/LibraryCall/callable_lib.C
+++ b/interpreter/cling/test/LibraryCall/callable_lib.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: clang -shared %S/call_lib.c -o%T/libcall_lib%shlibext
+// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib%shlibext
 // RUN: cat %s | %cling -L%T | FileCheck %s
 
 .L libcall_lib
diff --git a/interpreter/cling/test/Pragmas/add_env_path.C b/interpreter/cling/test/Pragmas/add_env_path.C
index ed7648c22e03abafeacf5885c146244bb7620d1f..15613866960cb5f4dad71b9067baba72da8c0d0f 100644
--- a/interpreter/cling/test/Pragmas/add_env_path.C
+++ b/interpreter/cling/test/Pragmas/add_env_path.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: mkdir -p %T/subdir && clang -shared %S/call_lib.c -o %T/subdir/libtest%shlibext
+// RUN: mkdir -p %T/subdir && clang -DCLING_EXPORT=%dllexport -shared %S/call_lib.c -o %T/subdir/libtest%shlibext
 // RUN: %setenv ENVVAR_LIB="%T/subdir" && %setenv ENVVAR_INC="%S/subdir"
 // RUN: cat %s | %cling -I %S -Xclang -verify 2>&1 | FileCheck %s
 
diff --git a/interpreter/cling/test/Pragmas/call_lib.c b/interpreter/cling/test/Pragmas/call_lib.c
index a51edc25cd6b7bbcb2898140c00c85667cf667e4..4cd6ea5fbb9691b3152b9b2cec10177b0adb4dd8 100644
--- a/interpreter/cling/test/Pragmas/call_lib.c
+++ b/interpreter/cling/test/Pragmas/call_lib.c
@@ -8,6 +8,6 @@
 
 // RUN: true
 // Used as library source by call.c
-int cling_testlibrary_function() {
+CLING_EXPORT int cling_testlibrary_function() {
   return 0x42;
 }
diff --git a/interpreter/cling/test/Pragmas/load.C b/interpreter/cling/test/Pragmas/load.C
index 50478c7beca5c23e6d9d04e42c944b70e7ca7add..7b1be3f572a55391dac7b008ce68c4999be4361d 100644
--- a/interpreter/cling/test/Pragmas/load.C
+++ b/interpreter/cling/test/Pragmas/load.C
@@ -6,7 +6,7 @@
 // LICENSE.TXT for details.
 //------------------------------------------------------------------------------
 
-// RUN: clang -shared %S/call_lib.c -o%T/libcall_lib%shlibext
+// RUN: clang -shared -DCLING_EXPORT=%dllexport %S/call_lib.c -o%T/libcall_lib%shlibext
 // RUN: cat %s | %cling -L %T -Xclang -verify 2>&1 | FileCheck %s
 
 #pragma cling load("DoesNotExistPleaseRecover") // expected-error@1{{'DoesNotExistPleaseRecover' file not found}}
diff --git a/interpreter/cling/test/lit.cfg b/interpreter/cling/test/lit.cfg
index 634ad4d3cce466ff05894eea28b16d1a3553effc..25c70d4a9df65fbe7e10c905552f0ad0a3f66601 100644
--- a/interpreter/cling/test/lit.cfg
+++ b/interpreter/cling/test/lit.cfg
@@ -267,9 +267,11 @@ else:
 if platform.system() in ['Windows']:
   config.substitutions.append( ('%nostdincxx', '-nostdinc') )
   config.substitutions.append(('%setenv', 'set'))
+  config.substitutions.append(('%dllexport', '"__declspec(dllexport)"'))
 else:
   config.substitutions.append( ('%nostdincxx', '-nostdinc++') )
   config.substitutions.append(('%setenv', 'export'))
+  config.substitutions.append(('%dllexport', ''))
 
 #Don't add tests to history
 os.environ['CLING_NOHISTORY'] = '1'