MATLAB: Do I get Linker errors while building a Simulink model for xPC target

'0x460'codeerrorfatallinkmodelnmakereturns-functionsimulinkSimulink Real-Timetargetu1077xpc

The Simulink model contains a block 'Blk1' generated using the S-function target. 'Blk1' was generated from a Subsystem 'subsys1' via the S-function target. subsys1 contains a user written S-function block. (cnt.c). I get the following error when I try to build the model:
### Linking ...
D:\MATLAB6p1\sys\perl\win32\bin\perl
D:\MATLAB6p1\rtw\c\tools\mkvc_lnk.pl trial1_sfun.lnk trial1_sfun.obj
rt_sim.obj rt_nonfinite.obj xpctarget.obj trial10_sf.obj
link /DEBUG /NOLOGO /DLL /DEF:xpcvcdll.def /Include:_malloc
D:\MATLAB6p1\toolbox\rtw\targets\xpc\target\build\lib\rttheap.lib rtwlib.lib
@trial1_sfun.lnk -out:trial1_sfun.dll
Creating library trial1_sfun.lib and object trial1_sfun.exp
trial1_sfun.obj : error LNK2001: unresolved external symbol _cnt
trial1_sfun.dll : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: 'link' : return code '0x460'
Stop.
I do not get this error when I build the model and I replace "Blk1" with "subsys1" (the original subsystem).

Best Answer

This issue has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
The problem is not xPC Target specific. It happens with grt as well.
The issue is that the Linker is not able to find the source C file for the S-function. In order to fix this, you need to specify the appropriate Make Command option(s) in your Simulation Parameters dialog box. To bring up this dialog box in a Simulink model, choose Simulation -> Simulation Parameters -> Real-Time Workshop. In this Dialog box, in the Make Command field, type the following:
make_rtw "USER_SRCS=my_source.c"
where "my_source.c" is your C-MEX S-function Source file.
Other Make Command options are documented in the Real-Time Workshop User's Guide: