Simulink ceval undefined reference when switching from Normal to Accelerator simulation mode

I created a simple Simulink model with a MATLAB function block which invokes a coder.ceval function:
function y = callDoubleIt(u)
%#codegen
y = 0.0
y = coder.ceval('doubleIt',u);
Within "Model Configuration Parameters", I defined the C code:
If I then create a model with a reference to the block in normal simulation mode, everything works as expected:
But if I switch the block from normal to accelerator, it blows up when trying to I try to run with an undefined reference during compilation:
object C:\Users\****\Documents\MATLAB\callDoubleIt_msf.exp
callDoubleItlib.lib(callDoubleIt.obj) : error LNK2019: unresolved external symbol doubleIt referenced in function callDoubleIt
C:\Users\****\Documents\MATLAB\callDoubleIt_msf.mexw64 : fatal error LNK1120: 1 unresolved externals
I am trying to do this same thing on a far more complicated model but I am running into the same issue with an undefined symbol. This is a simplified example. What am I doing wrong? Version is R2014a. Thanks.

 Respuesta aceptada

Edit (actual resolution): It turns out that there is a setting that needs to be enabled on the referenced model(s) in order to have their custom code settings be applied:
In short, you can run:
set_param(gcs, 'SupportModelReferenceSimTargetCustomCode', 'on');
for the referenced model(s) and it should include the declaration/definition for doubleIt.
Original incorrect response: If you look in "Code Generation->Custom Code" you'll see the same dialog as in "Simulation Target->Custom Code". By default the settings in those two panes are independent. Check the box "Use the same custom code settings as the Simulation Target" and you'll get those settings when generating code.
Hopefully that should resolve it.

4 comentarios

Cody
Cody el 11 de Dic. de 2014
Editada: Cody el 11 de Dic. de 2014
Thanks for the reply, Ryan. I tried all 3 permutations of the "Use the same custom code settings as Simulation Target" by setting it on only callDoubleIt, only on test_doubleit, and on both of them. It still gets the same compile error in all cases. Any other ideas?
Unfortunately I'm stumped. I'll ask some colleagues to see if they have any ideas.
It turns out that there is a setting that needs to be enabled on the referenced model(s) in order to have their custom code settings be applied:
In short, you can run:
set_param(gcs, 'SupportModelReferenceSimTargetCustomCode', 'on');
for the referenced model(s) and it should include the declaration/definition for doubleIt.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 10 de Dic. de 2014

Editada:

el 13 de Dic. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by