I\'m currently trying to build on Windows (with Intel compiler) a big project compiling very well on UNIX with CMake. Here is a reduced simple example of my problem.
It seems like you have a problem with finding dll's on your machine. As a temporary fix, you can try to rename your .dll file to .pyd.
When using Boost.Python, the default configuration is dynamic linking. To force static linking, define BOOST_PYTHON_STATIC_LIB
in the compilation. Consider either:
add_definitions(-DBOOST_PYTHON_STATIC_LIB)
within CMake#define BOOST_PYTHON_STATIC_LIB
before including boost/python.hpp
#define BOOST_PYTHON_STATIC_LIB
in boost/config/user.hpp
Boost.Python is an exception to the Boost_USE_STATIC_LIBS
CMake variable. The FindBoost documentation notes:
On Visual Studio and Borland compilers Boost headers request automatic linking to corresponding libraries. [...] Boost automatic linking typically requests static libraries with a few exceptions (such as Boost.Python).
Unfortunately, the BOOST_PYTHON_STATIC_LIB
option is neither listed in the Boost user settable options, Choosing a Boost.Python Library Binary, nor Boost.Python Configuration Information documentation.
A few other recommendations given your example code:
Py_Finalize()
. Some internal Boost.Python objects will remain alive during Py_Finalize()
, and only attempt to be deleted when Boost.Python unloads, causing the objects to attempt deletion with a non-existent interpreter.python.h
. If you must, consider including boost/python/detail/wrap_python.hpp
instead.python.h
(or the Boost.Python files). This restriction is imposed by Python (see here).The latter two recommendations documented in the #include issues section.