我在使用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
的提示。太棒了! - jorgecagcc
命令行在做什么。对于我的情况,我只执行类似前两个命令行的操作。 - Alex Eastman