MATLAB: Do I get a compile error when generating code for an automatically generated S-Function

codeEmbedded Codererrorfatalgenerationlnk1120lnk2019s-functionssfxpsetu32bitregioncompliantu1077

I am running into an error while generating code for an S-Function that I have previously build via the right-click menu 'C/C++ Code > Generate S-Function', based on a Simulink model I created. The error specifically mentions:
_Subsystem_sf.obj : error LNK2019: unresolved external symbol ssFxpSetU32BitRegionCompliant referenced in function mdlInitializeSizes
..\untitled.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64\link.EXE"' : return code '0x460'
Stop._
I want to make sure that the file 'ssFxpSetU32BitRegionCompliant', mentioned in the error, is included in the build.

Best Answer

Two possible workaround exist for the issue at hand:
  1. If you need to generate a Windows executable, please add the output of the following command to 'Configuration Parameters > Code Generation > Custom Code > Additional build information: Libraries' of the S-Function model:* >> fullfile(matlabroot,'extern\lib\win64\microsoft\libfixedpoint.lib')
  2. If you need to generate code for a specific target, please open the file '<MODELNAME>_sf.c' file in the '<MODELNAME>_sfcn_rtw' folder, and add the following statements before and after the 'ssFxpSetU32BitRegionCompliant(S, 1);' line:* Before: #if defined (MATLAB_MEX_FILE)* After: #endif