ECo "Undefined symbols for architecture x86_64"
3 views (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 17 Aug 2015
You specifically call upon State and Elements in the code: what are you expecting those to be?
Answers (1)
Sainath Varikuti
on 19 Aug 2015
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
0 Comments
See Also
Categories
Find more on C Matrix API in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!