MATLAB: Do I receive unresolved external symbol errors when building the project in MSVC Development Studio after creating the code using Real-Time Workshop 5.1 (R13SP1)

_mxfree_mxmallocdevelopmentexternallnk2001makefilemkfilemsvcr13r13sp1rtwsimulink codersp1studiosymbol [~]unresolved

Why do I receive unresolved external symbol errors when building my project in MSVC Development Studio after creating the code using Real-Time Workshop 5.1 (R13SP1)?
I built code for the Flanging demo (dspafxf.mdl) using Real-Time Workshop 5.1 (R13SP1) and Real-Time Workshop 5.0 (R13).
(NOTE: From the Simulation Parameters dialog box on the Real-Time Workshop tab, I chose "Visual C/C++ Project Makefile only for the grt_malloc target" and had to uncheck "Generate code only" in order for a .mak file to be created.)
Once I build the code, I brought the dspafxf.mak into MSVC Development Studio and then tried to compile the code. The code I built with RTW 5.0 (the .exe file) did not produce any errors, but the code from RTW 5.1 produced the following errors in MSVC Development Studio:
 
Linking...
sqdes_lin_floor_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sqdes_main_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sort_ascend_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sqdes_bin_ceil_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sqdes_bin_floor_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sqdes_lin_ceil_d_rt.obj : error LNK2001: unresolved external symbol _mxFree
sort_ascend_d_rt.obj : error LNK2001: unresolved external symbol _mxMalloc
sqdes_main_d_rt.obj : error LNK2001: unresolved external symbol _mxMalloc
sqdes_bin_ceil_d_rt.obj : error LNK2001: unresolved external symbol _mxCalloc
sqdes_bin_floor_d_rt.obj : error LNK2001: unresolved external symbol _mxCalloc
sqdes_lin_ceil_d_rt.obj : error LNK2001: unresolved external symbol _mxCalloc
sqdes_lin_floor_d_rt.obj : error LNK2001: unresolved external symbol _mxCalloc
sqdes_main_d_rt.obj : error LNK2001: unresolved external symbol _mxRealloc
.\Debug/dspafxf.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
dspafxf.exe - 14 error(s), 0 warning(s)

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This is a bug in Real-Time Workshop 5.1 (R13SP1) occurring due to the exclusion of particular source files. Our development staff is investigating this issue.
One possible workaround is to delete the $MATLAB\toolbox\rtw\dspblks\c\dspsqdesign directory from your R13SP1 install tree. This should prevent the files in it from being included in the [model].mak file.
Please note this workaround has not been verified yet.