ECo "Undefined symbols for architecture x86_64"

1 回表示 (過去 30 日間)
Chip
Chip 2015 年 8 月 17 日
回答済み: Sainath Varikuti 2015 年 8 月 19 日
I'm trying to compile a mex file and I got this error:
>> mex S-Function/coordinate_converter.cpp
Building with 'Xcode Clang++'.
Error using mex
Undefined symbols for architecture x86_64:
"State(double, Vector const&, double)", referenced from:
mdlOutputs(SimStruct_tag*, int) in coordinate_converter.o
"Elements(double, Vector const&)", referenced from:
mdlOutputs(SimStruct_tag*, int) in coordinate_converter.o
"Vector::Vector(int)", referenced from:
mdlOutputs(SimStruct_tag*, int) in coordinate_converter.o
"Vector::~Vector()", referenced from:
mdlOutputs(SimStruct_tag*, int) in coordinate_converter.o
"Vector::operator=(Vector const&)", referenced from:
mdlOutputs(SimStruct_tag*, int) in coordinate_converter.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
My mdlOutputs look like this:
static void mdlOutputs(SimStruct *S, int_T tid)
{
//Local variables
Vector y_in(6);
Vector y_out(6);
//Get parameters
real_T *Y_IN = (real_T *) ssGetInputPortRealSignal(S, 0);
for(int_T i = 0; i < 6; i++) y_in(i) = Y_IN[i];
//Computation
if(int(*mxGetPr(ssGetSFcnParam(S, 1))) == 1) // Cartesian > Keplerian
y_out = Elements(GM_Earth, y_in);
else if(int(*mxGetPr(ssGetSFcnParam(S, 1))) == 2) // Keplerian > Cartesian
y_out = State(GM_Earth, y_in, 0.0);
else
ssSetErrorStatus(S, "Wrong parameter, should be 1 or 2");
real_T *Y_OUT = ssGetOutputPortRealSignal(S, 0); //Output
for(int_T i = 0; i < 6; i++) Y_OUT[i] = y_out(i);
}
I would really appreciate if you could help me with this. Thank you so much.
  1 件のコメント
Walter Roberson
Walter Roberson 2015 年 8 月 17 日
You specifically call upon State and Elements in the code: what are you expecting those to be?

サインインしてコメントする。

回答 (1 件)

Sainath Varikuti
Sainath Varikuti 2015 年 8 月 19 日
Hi,
When performing mex, you have to include the source file with elements and state methods. You may refer to the following documentation page.
Regards, Sainath

カテゴリ

Help Center および File ExchangeC Matrix API についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by