Why do I receive linker errors when compiling a fixed-point Simulink S-functions?
12 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2012-12-10
编辑: MathWorks Support Team
2023-10-18
I wrote a fixed-point S-function that uses functions from the Fixed-Point S-Function API, such as:
- ssRegisterDataTypeFxpBinaryPoint
- ssRegisterDataTypeFxpSlopeBias
- ssRegisterDataTypeHalfPrecision
- ssRegisterDataTypeFxpScaledDouble
- ssRegisterDataTypeFxpFSlopeFixExpBias
- ssFxpSetU32BitRegionCompliant
- ssFxpGetU32BitRegionCompliant
- ssFxpSetU32BitRegion
- ssFxpGetU32BitRegion
When I compile the S-function using MEX, I receive the following error:
ERROR: >> mex sfun_user_fxp_asr.c
Building with 'Microsoft Visual C++ 2022 (C)'.
Error using mex
Creating library sfun_user_fxp_asr.lib and object sfun_user_fxp_asr.exp
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssRegisterDataTypeFxpBinaryPoint referenced in function mdlSetInputPortDataType
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeIsFxpFltApiCompat referenced in function isDataTypeSupported
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeStorageContainCat referenced in function isDataTypeSupported
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeFxpWordLength referenced in function mdlSetInputPortDataType
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeFxpIsSigned referenced in function mdlSetInputPortDataType
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeIsScalingPow2 referenced infunction isDataTypeSupported
sfun_user_fxp_asr.obj : error LNK2019: unresolved external symbol ssGetDataTypeFractionLength referenced in function mdlSetInputPortDataType
sfun_user_fxp_asr.mexw64 : fatal error LNK1120: 7 unresolved externals
采纳的回答
MathWorks Support Team
2023-10-18
编辑:MathWorks Support Team
2023-10-18
To compile a fixed-point S-function, additional steps must be used compared to standard C-MEX S-functions.
1. In your S-function, include "fixedpoint.c" and "fixedpoint.h". For more information, see:
2. Pass an extra argument, "-lfixedpoint", to the MEX command. For example:
>> mex('sfun_user_fxp_asr.c','-lfixedpoint')
Passing the extra argument should resolve the linker errors.
The documentation on that topic is located at: Creating MEX-Files
0 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!