I am having trouble reading a string (file name : 'aFile.csv') from SFunction parameter. The error I get doesn't make sense to me
I am using MSVC++(2017).
The error appears to come from ssGetSFcParam inside mxGetString
Here is a snippet of the code that has the proble (in the mdlStart method)
static void mdlStart(SimStruct *S)
{
FILE* fp;
char buffer[255];
char* fileStr;
char* paramStr;
int_T fstatus;
int_T pstatus;
const int_T flen = (int_T)mxGetN((ssGetSFcnParam(S, 0)))*sizeof(char)+1;
const int_T plen = (int_T)mxGetN((ssGetSFcnParam(S, 1)))*sizeof(char)+1;
fileStr = mxMalloc(flen);
paramStr = mxMalloc(plen);
fstatus = mxGetString((ssGetSFcParam(S,0)),fileStr,flen);
pstatus = mxGetString((ssGetSFcParam(S,1)),paramStr,plen);
real_T* Defval = (real_T *)mxGetData(PARAM_DEF2(S));
fp = fopen(fileStr, "r");
// additional code here, but has nothing to do with the error
mxFree(flen);
mxFree(plen);
fclose(fp);
}
Error using mex
Creating library FileReader.lib and object FileReader.exp FileReader.obj : error LNK2019: unresolved external symbol ssGetSFcParam referenced in function mdlStart FileReader.mexw64 : fatal error LNK1120: 1 unresolved externals
The error message says everything: there is no S-function method called ssGetSFcParam
. You need to use ssGetSFcnParam
, which you have used twice, and then also made a typo twice.