【发布时间】:2015-11-09 15:55:37
【问题描述】:
我的参数类型为
typedef double DP;
typedef const NRVec<DP> Vec_I_DP; //NRVec is a parametrized template class.
typedef NRVec<DP> Vec_DP, Vec_O_DP, Vec_IO_DP;
xa -> Vec_I_DP(30)
ya -> Vec_I_DP(30)
yp1 -> DP(30)
ypn -> DP(30)
y2 -> Vec_O_DP(30)
我的函数调用是
NR::spline(xa, ya, yp1, ypn, y2);
而函数声明是
void spline(Vec_I_DP &x, Vec_I_DP &y, const DP yp1, const DP ypn,Vec_O_DP &y2);
谁能告诉我,为什么会出现以下错误。
1>Hiwi.obj : error LNK2019: unresolved external symbol "void __cdecl NR::spline(class NRVec<double> const &,class NRVec<double> const &,double,double,class NRVec<double> &)" (?spline@NR@@YAXABV?$NRVec@N@@0NNAAV2@@Z) referenced in function "void __cdecl smooth_Line(double *,int *,int,int,double *,double *,int,int)" (?smooth_disp_Line@@YAXPANPAHHH00HH@Z)
【问题讨论】:
-
什么是宏 Vec_I_DP 和 Vec_O_DP?
-
问题似乎与链接有关,而不是模板实例化。你定义函数
NR::spline了吗?您是否将定义函数的文件包含到项目/makefile 中? -
函数在哪里定义?你链接反对它吗?请通过此检查:What is an undefined reference/unresolved external symbol error and how do I fix it?
标签: c++ templates numerical-recipes