Search code examples
boost-python

boost.python MSVC12 linker errors when exposing classes with docstring_options


I regularly expose c++ classes to python using boost.python & MSVC 12 (dynamic linking). Recently I have been trying to include documentation using the "docstring_options" class. The documentation examples work fine:

http://www.boost.org/doc/libs/1_54_0/libs/python/doc/v2/docstring_options.html

However, when I include a class and expose it I get linker errors:

error LNK2019: unresolved external symbol "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exception@boost@@YAXABVexception@std@@@Z) referenced in function "public: __thiscall boost::detail::shared_count::shared_count(void *,struct boost::python::converter::shared_ptr_deleter)"

I'm sure there is probably something simple I'm missing but I can't figure it out.

Many thanks in advance!

sample code spliced from the boost examples that gives this error for me.

#include <string>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/args.hpp>
#include <boost/python/docstring_options.hpp>
#include <boost/python.hpp>
struct World
{
void set(std::string msg) { this->msg = msg; }
std::string greet() { return msg; }
std::string msg;
};
int foo1(int i) { return i; }
int foo2(long l) { return static_cast<int>(l); }
int bar1(int i) { return i; }
int bar2(long l) { return static_cast<int>(l); }
namespace {
void wrap_foos()
{
    using namespace boost::python;
    def("foo1", foo1, arg("i"), "foo1 doc");
    def("foo2", foo2, arg("l"), "foo2 doc");
}
void wrap_bars()
{
    using namespace boost::python;
    bool show_user_defined = true;
    bool show_signatures = false;
    docstring_options doc_options(show_user_defined, show_signatures);
    def("bar1", bar1, arg("i"), "bar1 doc");
    def("bar2", bar2, arg("l"), "bar2 doc");

    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;

}
}
BOOST_PYTHON_MODULE(boost_py_doc_demo)
{
boost::python::docstring_options doc_options(false);
wrap_foos();
wrap_bars();
}

Solution

  • I compiled the latest version of boost (1.63) and now the problem has gone. I guess my old libraries were incomplete in some way.