c++ - 使用 boost::noncopyable 时 Python Boost 未定义符号
问题描述
我在使用 boost 和 python3.8 绑定代码时遇到问题
错误
Traceback (most recent call last):
File "boost-bindings/python_valve_controller.py", line 3, in <module>
import python_valve_controller
ImportError: /app/boost-bindings/python_valve_controller.so: undefined symbol: _ZTI18ArmouredValveCntrl
模块文件
#include <iostream>
#include "ArmouredValveCntrl.h"
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(python_valve_controller)
{
class_<ArmouredValveCntrl, boost::noncopyable>("ArmouredValveCntrl")
.def("coco_start", &ArmouredValveCntrl::coco_start)
;
};
ArmoredValveCntrl.h
#pragma once
#include "coco/runtime.h"
#include "Armour.h"
#include "PArmour.h"
#include "TestValveCntrl.h"
class ArmouredValveCntrl : public coco::BaseMultiThreadedEncapsulatingComponent {
public:
ArmouredValveCntrl();
~ArmouredValveCntrl();
void coco_start() override;
PArmourProvided &client() { return *client_; }
void set_logger_recursively(coco::StateMachineLogger *logger) override;
private:
Armour armour_;
SimulateValveCntrl testValve_;
PArmourProvided *client_;
};
我需要使用 boost::noncopyable,否则我会被删除一堆已删除的错误,例如:
/usr/include/boost/python/object/value_holder.hpp:133:13: error: use of deleted function 'ArmouredValveCntrl::ArmouredValveCntrl(const ArmouredValveCntrl&)'
133 | BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
| ^
In file included from /app/boost-bindings/python_valve_controller.cpp:5:
使用 boost::noncopyable 是好方法吗?在这种情况下,我该如何修复未定义的符号?
如果没有,我该如何修复所有已删除的错误(参考:使用已删除的函数与 boost::bind)?
解决方案
推荐阅读
- java - 这个循环执行多少次迭代?
- javascript - 将值一一插入到搜索字段中,同时用相同的按钮一一显示图像?
- html - 如何更改页面的资源 URL?
- mysql - Mysql Select 记录 '23:57:58' 和 '00:07:58' 之间的时间
- c - 有什么方法可以使用 sizeof 函数和 C 中的指针来获得正确的字符串大小
- javascript - 基于使用jquery的值在下拉列表中选择的项目不起作用
- android - textInputLayout 的右侧边框在 alertdialog 中被裁剪
- javascript - 如何创建 JS 对象并将其附加到数组中
- android - Oreo 及以上版本中的 FCM 后台通知
- spring - Spring Boot 如何决定应用程序的活跃状态?