【问题标题】:Boost.Python - undefined symbols error even though the lib files are linkedBoost.Python - 即使链接了 lib 文件,也会出现未定义的符号错误
【发布时间】:2013-08-22 20:01:38
【问题描述】:

我正在测试 Boost.Python,但遇到了一些问题。

我成功地完成了“Hello World”示例 (http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/index.html) - 一切都已编译,我能够在 Python 中正确使用 .so。

但是,一旦我将类引入我的测试文件 (http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/python/exposing.html),编译器就开始尖叫

    Undefined symbols for architecture x86_64:
      "boost::python::objects::function_object(boost::python::objects::py_function const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&)", referenced from:
          boost::python::api::object boost::python::detail::make_function_aux<void (World::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), boost::python::default_call_policies, boost::mpl::vector3<void, World&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, mpl_::int_<0> >(void (World::*)(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >), boost::python::default_call_policies const&, boost::mpl::vector3<void, World&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
          boost::python::api::object boost::python::detail::make_function_aux<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > (World::*)(), boost::python::default_call_policies, boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, World&>, mpl_::int_<0> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > (World::*)(), boost::python::default_call_policies const&, boost::mpl::vector2<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, World&> const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
          boost::python::api::object boost::python::detail::make_function_aux<void (*)(_object*), boost::python::default_call_policies, boost::mpl::vector2<void, _object*>, mpl_::int_<0> >(void (*)(_object*), boost::python::default_call_policies const&, boost::mpl::vector2<void, _object*> const&, std::__1::pair<boost::python::detail::keyword const*, boost::python::detail::keyword const*> const&, mpl_::int_<0>) in SHLibPy.o
      "boost::python::objects::register_dynamic_id_aux(boost::python::type_info, std::__1::pair<void*, boost::python::type_info> (*)(void*))", referenced from:
          void boost::python::objects::register_dynamic_id<World>(World*) in SHLibPy.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

似乎暗示lib文件没有链接,但我已经将它们包含在XCode中

我错过了什么吗?非常感谢!

【问题讨论】:

    标签: xcode boost boost-python


    【解决方案1】:

    我找到了原因。原来我正在使用支持 C++11 的标准库。为了解决这个问题,我使用 brew 重建了 boost,如下所示

        brew -v install --with-icu --build-from-source --with-c++11 boost
    

    【讨论】:

    • 我遇到了同样的问题。现在尝试您的解决方案。重建需要一段时间:-(
    • MakefileJamroot 会有所帮助...这对我不起作用
    猜你喜欢
    • 2014-06-22
    • 1970-01-01
    • 1970-01-01
    • 2017-05-16
    • 1970-01-01
    • 2014-04-15
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多