diff --git a/test/Jamfile b/test/Jamfile
index 4e67545a2..5dc601610 100644
--- a/test/Jamfile
+++ b/test/Jamfile
@@ -43,6 +43,9 @@ lib libtorrent_test
: # default build
shared
+
+ : # user-requirements
+ shared:TORRENT_LINK_TEST_SHARED
;
lib advapi32 : : Advapi32 ;
diff --git a/test/test.hpp b/test/test.hpp
index 3f0d0dd06..e4423e1f6 100644
--- a/test/test.hpp
+++ b/test/test.hpp
@@ -39,10 +39,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
-#ifdef TORRENT_BUILDING_TEST_SHARED
+#if defined TORRENT_BUILDING_TEST_SHARED
#define EXPORT BOOST_SYMBOL_EXPORT
-#else
+#elif defined TORRENT_LINK_TEST_SHARED
#define EXPORT BOOST_SYMBOL_IMPORT
+#else
+#define EXPORT
#endif
// the unit tests need access to these.