加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – swig错误:未定义的符号

发布时间:2020-12-20 12:27:47 所属栏目:Python 来源:网络整理
导读:我遇到了swig和我的问题,看起来我的代码中的一个数据成员是一个未定义的符号.我在网上找到了关于如何修复功能的答案,但这让我很困惑. 我的错误是: Traceback (most recent call last): File "./test1.py",line 5,in module from volumes import * File "/sc
我遇到了swig和我的问题,看起来我的代码中的一个数据成员是一个未定义的符号.我在网上找到了关于如何修复功能的答案,但这让我很困惑.

我的错误是:

Traceback (most recent call last):
  File "./test1.py",line 5,in <module>
    from volumes import *
  File "/scratch/rjkern/projects/RJKERN_volrend/scripts/volumes.py",line 26,in <module>
    _volumes = swig_import_helper()
  File "/scratch/rjkern/projects/RJKERN_volrend/scripts/volumes.py",line 22,in swig_import_helper
    _mod = imp.load_module('_volumes',fp,pathname,description)
ImportError: /scratch/rjkern/projects/RJKERN_volrend/scripts/_volumes.so: undefined symbol: _ZN13ConstantColorC1ESt10shared_ptrI5ColorE

这是我的代码:

/*
 *  ColorOperations.h
 */

#ifndef ___COLOROPS___
#define ___COLOROPS___

#include "Color.h"
#include "ProgressMeter.h"
#include "Vector.h"
#include "Volume.h"
#include "VolumeOperations.h"

#include <memory>

using namespace std;

class ConstantColor : public Volume<Color>{
    shared_ptr <Color> color;

public:
    ConstantColor(const shared_ptr<Color>& _color);

    const Color eval(const Vector& P) const;
    Color grad(const Vector& P);
};
#endif

和:

/*
 *  ColorOperations.cpp
 */

#include "ColorOperations.h"

ConstantColor::ConstantColor(const shared_ptr<Color>& _color){
    color = _color;
}

const Color ConstantColor::eval(const Vector& P)const{
    return *color;
}

解决方法

我们可以用c filt去除符号名称:

c++filt _ZN13ConstantColorC1ESt10shared_ptrI5ColorE

这给了:

ConstantColor::ConstantColor(std::shared_ptr<Color>)

即你的构造函数,它采用shared_ptr.但是,只会报告第一个未解决的符号.

请注意,这里它不是引用,但您的构造函数看起来像是引用.您.i或其他文件中某处可能的拼写错误可能解释为什么某些东西认为存在非参考版本.

另一个可能的解释是,您已经将您的包装器(即已编译的卷_wrap.cxx)构建到共享对象,但未将已编译的ColourOperations.cpp链接到该对象.

或者,如果您已将它链接到linked it in the wrong order and thus it was judged as not needed by the linker,则可能是这样.如果是这种情况,请确保在链接器命令行上最后有-lcolour_library / colour_library.a / ColorOperatios.o. (这个名字有猜测).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读