From: Richard Hodges on
I am getting an error trying to use a tlc file with a
legacy_code tool generated block. I had to hand modify the
legacy_code generated cpp file and then call mex from the
matlab command line in order to allow the block to work with
frame-based data. I also had to comment out the line

SS_OPTION_USE_TLC_WITH_ACCELERATOR |

in the call to ssSetOptions because if I include this line I
get an error when I use the block in a model in accelerated
mode. For many purposes commenting out this line is OK. But
for maximum efficiency, and also in order to use the block
in a model reference, I do need to have the mentioned option
enabled. Here is the error message I get when I try to run a
model in accelerator mode with this option enabled:


Problem creating Accelerator MEX file for model
'ultrasonic'. Error returned is:
Error using ==> accelbuild_private at 26
Error using ==> tlc_new
Error: File: C:\Program
Files\MATLAB\R2007b\rtw\c\tlc\lib\utillib.tlc Line: 418
Column: 8
%exit directive: Real-Time Workshop Fatal: This S-Function
generated by the Legacy Code Tool must be only used with the
C++ Target Language


This is troubling because my block's code is all written in
C++, and I set the language option to 'C++' in the legacy
code object that was used to create the block.

Can you help me figure out what is wrong and how to get past
this problem?

From: Praetorian on
On Oct 1, 11:19 am, "Richard Hodges"
<richard.hodges.nos...(a)plantronics.com> wrote:
> I am getting an error trying to use a tlc file with a
> legacy_code tool generated block. I had to hand modify the
> legacy_code generated cpp file and then call mex from the
> matlab command line in order to allow the block to work with
> frame-based data. I also had to comment out the line
>
> SS_OPTION_USE_TLC_WITH_ACCELERATOR |
>
> in the call to ssSetOptions because if I include this line I
> get an error when I use the block in a model in accelerated
> mode. For many purposes commenting out this line is OK. But
> for maximum efficiency, and also in order to use the block
> in a model reference, I do need to have the mentioned option
> enabled. Here is the error message I get when I try to run a
> model in accelerator mode with this option enabled:
>
> Problem creating Accelerator MEX file for model
> 'ultrasonic'. Error returned is:
> Error using ==> accelbuild_private at 26
> Error using ==> tlc_new
> Error: File: C:\Program
> Files\MATLAB\R2007b\rtw\c\tlc\lib\utillib.tlc Line: 418
> Column: 8
> %exit directive: Real-Time Workshop Fatal: This S-Function
> generated by the Legacy Code Tool must be only used with the
> C++ Target Language
>
> This is troubling because my block's code is all written in
> C++, and I set the language option to 'C++' in the legacy
> code object that was used to create the block.
>
> Can you help me figure out what is wrong and how to get past
> this problem?

Richard,
Do you have the '%implements' directive at the top of your TLC file?
This should specify C++. Also, when this error happens you should see
a TLC stack trace in the Matlab command window; I think the error
message that you've copy pasted is from the error dialog that pops up
but that one only shows the final file in the stack and so is not very
useful for debugging.

Ashish.