【发布时间】:2015-07-19 10:52:42
【问题描述】:
我目前尝试实现的是通过 Boost.Python 构建我的 C++ 类的 python 映射。 在此之后,我想在搅拌机插件中使用生成的共享库,以便能够利用来自映射 C++ 类的现有功能。
我已经可以构建我的共享库并在 python 中编写示例脚本,这些脚本也在使用我的库。
这里一切正常,但问题是,一旦我尝试在附加组件中使用它,只要我在崩溃报告中添加带有这个小提示的导入语句,Blender 2.74 就会一直崩溃:
6 libboost_python.dylib 0x000000010aa7cc3e boost::python::detail::init_module(PyModuleDef&, void (*)()) + 30 (module.cpp:44)
在 boost 行 41-46 内的 module.cpp 中:
BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef& moduledef, void(*init_function)())
{
return init_module_in_scope(
PyModule_Create(&moduledef),
init_function);
}
我的 boost 1_58 是使用 Python 3.4.2 编译的:
otool -L /usr/local/lib/libboost_python.dylib
/usr/local/lib/libboost_python.dylib:
libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/Library/Frameworks/Python.framework/Versions/3.4/Python (compatibility version 3.4.0, current version 3.4.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
从那个目录运行 python3 bin 给了我:
python3
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 5 2014, 20:42:22)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
Blender Python 控制台给了我:
PYTHON INTERACTIVE CONSOLE 3.4.2 (default, Nov 25 2014, 12:01:44) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)]
Command History: Up/Down Arrow
Cursor: Left/Right Home/End
Remove: Backspace/Delete
Execute: Enter
Autocomplete: Ctrl-Space
Zoom: Ctrl +/-, Ctrl-Wheel
Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bpy.utils, bgl, blf, mathutils
Convenience Imports: from mathutils import *; from math import *
Convenience Variables: C = bpy.context, D = bpy.data
>>>
我自己的项目也使用这个 python 版本。 Blender 也使用这个 Python 版本。
我真的不知道接下来要尝试什么,因为在独立模式下,一切都按预期工作。 此外,当我在 Blenders 文本编辑器中运行具有 import 语句的新脚本时,甚至会发生崩溃。
有人使用过 Boost.Python 和 Blender 吗?
提前致谢
更新: 在调试模式下构建并运行搅拌机后,我得到以下状态:
这看起来不正确,首先描述了崩溃。 还在寻找原因……
【问题讨论】:
-
作为快速检查,您是否尝试过构建早期版本的 boost-python? 1.55 似乎比 1.58 更稳定。
-
我没有尝试过,因为最近才添加了对 python 3.4 的支持,因此无法与 blender 2.74 结合使用。我现在从源代码编译搅拌机,以便能够在调试模式下运行它。我现在收到以下错误:致命的 Python 错误:PyThreadState_Get:没有当前线程...目前正在调查此
-
我不熟悉搅拌机,但是是什么阻止您针对 python 3.4 构建 boost-python 1.55?
标签: python c++ blender python-3.4 boost-python