c-mex S-Function error in desktop real-time external mode: Error occurred while executing External Mode MEX-file ‘sldrtext’: Error loading real-time image: undefined symbol
I have encountered some issues with an S-Function I developed using c-mex. The purpose of my S-Function is to add two inputs together, and I have implemented this functionality using external c source code and header files. Here are the contents of these files:
myadd.h
int myadd(int a, int b);
myadd.c
#include "myadd.h"
int myadd(int a, int b)
{
return a+b;
}
and my S-Function is mysfun.c, its output function is:
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
I compiled them along with my S-Function using the following command:
mex mysfun.c myadd.c
The compilation process showed no errors. Next, I tested the S-Function in normal mode in Simulink, and it indeed worked properly. However, when I switched to Simulink Desktop Real-Time’s external mode, I encountered the following error message:
”’
Error occurred while executing External Mode MEX-file ‘sldrtext’: Error loading real-time image: undefined symbol "myadd"
”’
But when I implement myadd() function directly in mysfun.c, like:
int myadd(int a, int b)
{
return a+b;
}
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
the execution in external mode worked properly. I have no idea what is the problem.
Could someone please help me understand this error message? Thank you!I have encountered some issues with an S-Function I developed using c-mex. The purpose of my S-Function is to add two inputs together, and I have implemented this functionality using external c source code and header files. Here are the contents of these files:
myadd.h
int myadd(int a, int b);
myadd.c
#include "myadd.h"
int myadd(int a, int b)
{
return a+b;
}
and my S-Function is mysfun.c, its output function is:
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
I compiled them along with my S-Function using the following command:
mex mysfun.c myadd.c
The compilation process showed no errors. Next, I tested the S-Function in normal mode in Simulink, and it indeed worked properly. However, when I switched to Simulink Desktop Real-Time’s external mode, I encountered the following error message:
”’
Error occurred while executing External Mode MEX-file ‘sldrtext’: Error loading real-time image: undefined symbol "myadd"
”’
But when I implement myadd() function directly in mysfun.c, like:
int myadd(int a, int b)
{
return a+b;
}
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
the execution in external mode worked properly. I have no idea what is the problem.
Could someone please help me understand this error message? Thank you! I have encountered some issues with an S-Function I developed using c-mex. The purpose of my S-Function is to add two inputs together, and I have implemented this functionality using external c source code and header files. Here are the contents of these files:
myadd.h
int myadd(int a, int b);
myadd.c
#include "myadd.h"
int myadd(int a, int b)
{
return a+b;
}
and my S-Function is mysfun.c, its output function is:
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
I compiled them along with my S-Function using the following command:
mex mysfun.c myadd.c
The compilation process showed no errors. Next, I tested the S-Function in normal mode in Simulink, and it indeed worked properly. However, when I switched to Simulink Desktop Real-Time’s external mode, I encountered the following error message:
”’
Error occurred while executing External Mode MEX-file ‘sldrtext’: Error loading real-time image: undefined symbol "myadd"
”’
But when I implement myadd() function directly in mysfun.c, like:
int myadd(int a, int b)
{
return a+b;
}
static void mdlOutputs(SimStruct *S, int_T tid)
{
const real_T *u = (const real_T*) ssGetInputPortSignal(S,0);
real_T *y = ssGetOutputPortSignal(S,0);
y[0] = myadd((int)u[0],10);
}
the execution in external mode worked properly. I have no idea what is the problem.
Could someone please help me understand this error message? Thank you! c-mex, s-function, real-time MATLAB Answers — New Questions