Compiler is invoked even though "Generate Code Only" is specified.

I have created a simple Simulink model and I'm attempting to generate C code. I'm using ert.tlc for the system target. I've specified "Generate Code Only" in the model's Configuration Parameters -> Real-Time Workshop options.
I get compiler errors when I build the model. The lcc compiler is called, even though I specified "Generate Code Only". I see the lcc compiler errors in the MATLAB command window.
How to I generate code without invoking the compiler.
Thanks, Tim
I have R2009b.

Answers (4)

My guess is that you have Stateflow, Embedded MATLAB or Model Reference (Accelerator mode) blocks in your model that need to generate and build code to update the model and propagate signal types, dimensions, etc. Is there a reason you want to avoid this?
I'm trying to generate code for an embedded processor. I have two Embedded MATLAB function blocks in my model, both of which call external C functions. I call these functions as in this example:
eml.ceval('GetDataAsFixed', eml.ref(X), ChannelNum, NumSamples);
I'm trying to generate C code only from MATLAB. I will then copy the generated code over to a separate project and use my IDE to compile it. Does this sound feasible?
Thanks, Tim

2 Comments

Yes, that should be feasible. However, for the purpose of simulation, it is necessary that LCC be called to generate a MEX-file corresponding to the Embedded MATLAB block - this is only needed for Simulink engine propagation and will not have any direct effect on the generated code.
I am having the same problem: I want Simulink to generate code which I will link using my external build system for an embedded Arm processor.
However I am getting Microsoft Visual Studio link errors, and these are preventing the <model>.c code from being generated.
Can you explain more why the host build has to occur?
The function I am trying to call in my external source file in turn calls many other functions, many of which have hardware dependancies. That will work fine when I do my build, but Simulink wants to find all of these other functions, which are sprayed all over my build system.
Can I just get Embedded Coder to generate the 'C' code without needing to build the Simulink code?

Sign in to comment.

Thanks for your help. However, due to the compiler error, MATLAB does not generate the C code. The directory where the code should be generated is created but it's empty.
The compiler is complaining that it can't open the directory where I have my source code and header files. The directory is valid and it exists and it contains source code, but I get this error from the compiler:
c:\matlab\r2009b\sys\lcc\bin\lccmake: Couldn't open C:\Work\firmware\Projects\VDAQ\trunk\VDAQ GetLastError() = 5
I specify this directory in Configuration Parameters -> Custom Code, under the "Include Directories" and "Source Files".
Any idea why MATLAB can't open the directory?
Thanks, Tim
I speculate that for whatever reason, it is trying to open the directory as a file. For example if somehow the directory was named as a {specific} Source File.
I have not worked with that tool, but putting together some things other people have said, it would not surprise me if the Source Files area had to explicitly name each source file. There is not usually equivalent of a "source file include path" in the IDE I have used: usually you either have to give the tools either paths relative to your current directory or else absolute paths.

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Asked:

Tim
on 22 Jun 2011

Commented:

on 13 Mar 2020

Community Treasure Hunt

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

Start Hunting!