Why do I receive an "unresolved external symbol" error during the linking stage when I try to compile generated code from DSP Blockset blocks?

13 views (last 30 days)
I am trying to use the code generated by embedded coder. It works fine if my model contains blocks from Simulink library and Fixed-Point Blockset. However, when I tried to use the blocks from DSP blockset, I get the following errors of "unresolved external symbol" during the linking stage. For example, if I use the "FFT" block, I will get the following errors:
 
error LNK2001: unresolved external symbol _MWDSP_DblLen_TBL_Z
error LNK2001: unresolved external symbol _MWDSP_R2DIT_TBLS_Z
error LNK2001: unresolved external symbol _MWDSP_FFTInterleave_BR_D

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Nov 2016
To avoid this error, you need to include the required files in your compiler program.
1. First, you need to open your model that uses DSP Blockset blocks, then look into each block to see if an S-function is used for the block.
If it is used, record the S-function name and look at the corresponding TLC file for that S-function. The name of the corresponding TLC file will have the same name as the S-function name.
For example, the FFT block uses an S-function called "sdspfft2.dll". You will need to locate the "sdspfft2.tlc" at the following directory:
$MATLABROOT\toolbox\dspblks\dspmex\tlc_c
then do a search for the keyword: "Include_rt_header".
A typical line will look like this:
 
%<Include_rt_header(block,"dspfft_rt")>
You then need to add all header files in your compiler program. The header files can be found at the following directories:
$MATLABROOT\toolbox\dspblks\include
2. After you generate the code for the model, you should see a C source file called model.c, where model is the name of your Simulink model.
Open model.c, look for all lines that start with:
 
MWDSP_........
In Windows, go to "Search for Files and Folders", perform a search for the text after MWDSP_ in the following folder:
$MATLABROOT\toolbox\rtw\dspblks\c
For example, if you use the FFT block, you will see a line like:
MWDSP_FFTInterleave_BR_D(&rtb_FFT[0], &untitled_P.Constant_Value[0], 1, 4);
in the model.c file. You should then search for "FFTInterleave_BR_D" in the folder $MATLABROOT\toolbox\rtw\dspblks\c.
This will come back with a result C file called "fft_interleave_br_d_rt.c". You also need to include this C source file in your compiler program.
You need to do this for every MWDSP_.... line that appears in the model.c file.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!