2017-02-15 52 views
0

我经常使用boost.python & MSVC 12(动态链接)将C++类暴露给python。最近我一直试图使用“docstring_options”类来包含文档。该文档的例子做工精细:当使用docstring_options暴露类时boost.python MSVC12链接器错误

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

然而,当我包括类,并揭露它,我得到的链接错误:

错误LNK2019:无法解析的外部符号“无效__cdecl的boost :: throw_exception(类STD :: exception exception &)“(?throw_exception @ boost @@ YAXABVexception @ std @@@ Z)在函数”public:__thiscall boost :: detail :: shared_count :: shared_count(void *,struct boost :: python ::转换器:: 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(); 
} 

回答

0

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