diff --git a/build/Jamfile b/build/Jamfile
index 235c5190..a8ad3776 100644
--- a/build/Jamfile
+++ b/build/Jamfile
@@ -137,6 +137,8 @@ rule lib_boost_numpy ( is-py3 ? )
numpy/scalars.cpp
numpy/ufunc.cpp
: # requirements
+ static:BOOST_NUMPY_STATIC_LIB
+ BOOST_NUMPY_SOURCE
[ cond [ python.numpy ] : /python//python_for_extensions ]
[ unless [ python.numpy ] : no ]
$(numpy-include)
@@ -150,6 +152,7 @@ rule lib_boost_numpy ( is-py3 ? )
: # default build
shared
: # usage requirements
+ static:BOOST_NUMPY_STATIC_LIB
on:BOOST_DEBUG_PYTHON
;
}
diff --git a/include/boost/python/numpy.hpp b/include/boost/python/numpy.hpp
index cd5876a8..18a6389d 100644
--- a/include/boost/python/numpy.hpp
+++ b/include/boost/python/numpy.hpp
@@ -13,6 +13,7 @@
#include
#include
#include
+#include
namespace boost { namespace python { namespace numpy {
@@ -26,7 +27,7 @@ namespace boost { namespace python { namespace numpy {
* and "import_ufunc()", and then calls
* dtype::register_scalar_converters().
*/
-void initialize(bool register_scalar_converters=true);
+BOOST_NUMPY_DECL void initialize(bool register_scalar_converters=true);
}}} // namespace boost::python::numpy
diff --git a/include/boost/python/numpy/config.hpp b/include/boost/python/numpy/config.hpp
new file mode 100644
index 00000000..6f39d3ce
--- /dev/null
+++ b/include/boost/python/numpy/config.hpp
@@ -0,0 +1,78 @@
+// (C) Copyright Samuli-Petrus Korhonen 2017.
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// The author gratefully acknowleges the support of NMR Solutions, Inc., in
+// producing this work.
+
+// Revision History:
+// 15 Feb 17 Initial version
+
+#ifndef CONFIG_NUMPY20170215_H_
+# define CONFIG_NUMPY20170215_H_
+
+# include
+
+/*****************************************************************************
+ *
+ * Set up dll import/export options:
+ *
+ ****************************************************************************/
+
+// backwards compatibility:
+#ifdef BOOST_NUMPY_STATIC_LIB
+# define BOOST_NUMPY_STATIC_LINK
+# elif !defined(BOOST_NUMPY_DYNAMIC_LIB)
+# define BOOST_NUMPY_DYNAMIC_LIB
+#endif
+
+#if defined(BOOST_NUMPY_DYNAMIC_LIB)
+# if defined(BOOST_SYMBOL_EXPORT)
+# if defined(BOOST_NUMPY_SOURCE)
+# define BOOST_NUMPY_DECL BOOST_SYMBOL_EXPORT
+# define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_EXPORT
+# define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_EXPORT
+# define BOOST_NUMPY_BUILD_DLL
+# else
+# define BOOST_NUMPY_DECL BOOST_SYMBOL_IMPORT
+# define BOOST_NUMPY_DECL_FORWARD BOOST_SYMBOL_FORWARD_IMPORT
+# define BOOST_NUMPY_DECL_EXCEPTION BOOST_EXCEPTION_IMPORT
+# endif
+# endif
+
+#endif
+
+#ifndef BOOST_NUMPY_DECL
+# define BOOST_NUMPY_DECL
+#endif
+
+#ifndef BOOST_NUMPY_DECL_FORWARD
+# define BOOST_NUMPY_DECL_FORWARD
+#endif
+
+#ifndef BOOST_NUMPY_DECL_EXCEPTION
+# define BOOST_NUMPY_DECL_EXCEPTION
+#endif
+
+// enable automatic library variant selection ------------------------------//
+
+#if !defined(BOOST_NUMPY_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_NUMPY_NO_LIB)
+//
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it:
+//
+#define BOOST_LIB_NAME boost_numpy
+//
+// If we're importing code from a dll, then tell auto_link.hpp about it:
+//
+#ifdef BOOST_NUMPY_DYNAMIC_LIB
+# define BOOST_DYN_LINK
+#endif
+//
+// And include the header that does the work:
+//
+#include
+#endif // auto-linking disabled
+
+#endif // CONFIG_NUMPY20170215_H_
diff --git a/include/boost/python/numpy/dtype.hpp b/include/boost/python/numpy/dtype.hpp
index 1284f9e5..32bb3d4a 100644
--- a/include/boost/python/numpy/dtype.hpp
+++ b/include/boost/python/numpy/dtype.hpp
@@ -14,6 +14,7 @@
#include
#include
+#include
#include
#include
@@ -25,7 +26,7 @@ namespace boost { namespace python { namespace numpy {
*
* @todo This could have a lot more interesting accessors.
*/
-class dtype : public object {
+class BOOST_NUMPY_DECL dtype : public object {
static python::detail::new_reference convert(object::object_cref arg, bool align);
public:
diff --git a/include/boost/python/numpy/matrix.hpp b/include/boost/python/numpy/matrix.hpp
index af20e8f9..43335e1f 100644
--- a/include/boost/python/numpy/matrix.hpp
+++ b/include/boost/python/numpy/matrix.hpp
@@ -14,6 +14,8 @@
#include
#include
#include
+#include
+
namespace boost { namespace python { namespace numpy {
@@ -27,7 +29,7 @@ namespace boost { namespace python { namespace numpy {
* bad things happen when Python shuts down. I think this solution is safe, but I'd
* love to get that confirmed.
*/
-class matrix : public ndarray
+class BOOST_NUMPY_DECL matrix : public ndarray
{
static object construct(object_cref obj, dtype const & dt, bool copy);
static object construct(object_cref obj, bool copy);
@@ -59,7 +61,7 @@ public:
* return a numpy.matrix instead.
*/
template
-struct as_matrix : Base
+struct BOOST_NUMPY_DECL as_matrix : Base
{
static PyObject * postcall(PyObject *, PyObject * result)
{
diff --git a/include/boost/python/numpy/ndarray.hpp b/include/boost/python/numpy/ndarray.hpp
index 2985907b..9ad0f20e 100644
--- a/include/boost/python/numpy/ndarray.hpp
+++ b/include/boost/python/numpy/ndarray.hpp
@@ -16,6 +16,8 @@
#include
#include
#include
+#include
+
#include
namespace boost { namespace python { namespace numpy {
@@ -26,7 +28,8 @@ namespace boost { namespace python { namespace numpy {
* @todo This could have a lot more functionality (like boost::python::numeric::array).
* Right now all that exists is what was needed to move raw data between C++ and Python.
*/
-class ndarray : public object
+
+class BOOST_NUMPY_DECL ndarray : public object
{
/**
diff --git a/include/boost/python/numpy/ufunc.hpp b/include/boost/python/numpy/ufunc.hpp
index 9262b378..4c2331c9 100644
--- a/include/boost/python/numpy/ufunc.hpp
+++ b/include/boost/python/numpy/ufunc.hpp
@@ -15,6 +15,7 @@
#include
#include
#include
+#include
namespace boost { namespace python { namespace numpy {
@@ -34,7 +35,7 @@ namespace boost { namespace python { namespace numpy {
* It's more dangerous than most object managers, however - maybe it actually belongs in
* a detail namespace?
*/
-class multi_iter : public object
+class BOOST_NUMPY_DECL multi_iter : public object
{
public: