【问题标题】:boost.python MSVC12 linker errors when exposing classes with docstring_options使用 docstring_options 公开类时 boost.python MSVC12 链接器错误
【发布时间】:2017-07-04 10:11:42
【问题描述】:

我经常使用 boost.python 和 MSVC 12(动态链接)将 c++ 类公开给 python。最近我一直在尝试使用“docstring_options”类来包含文档。文档示例工作正常:

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

但是,当我包含一个类并公开它时,我会收到链接器错误:

错误 LNK2019:函数“public: __thiscall boost: :detail::shared_count::shared_count(void *,struct boost::python::converter::shared_ptr_deleter)"

我确定我可能缺少一些简单的东西,但我无法弄清楚。

非常感谢!

从 boost 示例中拼接的示例代码为我提供了此错误。

#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();
}

【问题讨论】:

    标签: boost-python


    【解决方案1】:

    我编译了最新版本的 boost (1.63),现在问题已经解决了。我想我的旧图书馆在某种程度上是不完整的。

    【讨论】:

      猜你喜欢
      • 2013-06-26
      • 1970-01-01
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多