Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compile Issues - Simulink RTW Auto-generated Code

496 views
Skip to first unread message

Jeremy Goerner

unread,
Mar 5, 2008, 6:45:07 PM3/5/08
to
I have a Simulink model on which I've used the RTW tool to
generate some C code. My task was basically to generate an
API to wrap around the automatically generated code so that
our customers could make easy use of the functions
generated by Simulink and RTW by calling one of our API
functions.

The API is simple. All it does is call the RTW-generated
functions, in effect isolating the end-user from the mess
of code. My plan is eventually to build my API into a
single object file for distribution to the customer, who
has plans to integrate it into their existing FORTRAN
codebase.

Anyhow, my issue comes when I've tried to build my project.
I get no errors nor warnings with the code that I myself
have added and modifed. I get a lot of errors which would
seem to indicate that the right include files for the pre-
generated code are not being found. The compiler can't find
the right types, for example.

----------------------------------------------------

`int32_T' undeclared (first use in this function)
SAL_API rt_rand.c line 33

`real_T' undeclared (first use in this function)
SAL_API rt_rand.c line 35

...

simstruc_types.h: No such file or directory SAL_API
rtwtypes.h line 16

tmwtypes.h: No such file or directory SAL_API rtwtypes.h
line 12

simstruc.h: No such file or directory SAL_API
Analog_Sim_LoneStar_rev4.h line 18

fixedpoint.h: No such file or directory SAL_API
Analog_Sim_LoneStar_rev4.h line 19

rt_logging.h: No such file or directory SAL_API
Analog_Sim_LoneStar_rev4.h line 20

rtlibsrc.h: No such file or directory SAL_API
Analog_Sim_LoneStar_rev4.h line 24


----------------------------------------------------

And so on.

To my knowledge, and I have checked several times, ALL of
the files that were auto-generated were copied into my new
project folder in the exact relations that they were when
they were auto-generated.

Does anyone have any idea as to why the auto-generated code
would be throwing these errors? Is there a place on my
computer to access these certain include files I seem to be
lacking and get them into the proper directories?

I am also noticing that every time I build or compile, I
get varying numbers of errors and warnings, though all seem
to come from the auto-generated files. The range is
anywhere from 20 to 900 errors. This may be an issue with
my compiler, but it may not. Any help on this issue as well
would be appreciated.

Thanks.

Riccardo

unread,
Mar 6, 2008, 4:03:01 AM3/6/08
to
"Jeremy Goerner" <jdg...@gmail.com> wrote in message <fqnba3
$d2p$1...@fred.mathworks.com>...


Jeremy,

your compilation errors are due to the missing header files
in your build process (e.g. uint32_T and other types are
defined in tmwtypes.h - which may be found in
<MATLABROOT>\extern\include for my version).

Generally most of those can be found in directories
included by the Matlab path, although some may get
generated as well, depending on the version of TMW tools
and the type of RTW target.
Typical locations are :
<MATLABROOT>\extern\include
<MATLABROOT>\simulink\include

There are several ways of getting hold of those files in
your build, but perhaps the simplest of all is to stick the
relevant search directories into your makefile, so that
those headers become available.
Otherwise have a look at the template makefiles (.tmf)
under <MATLABROOT>\rtw\c\* to get an idea of how to use the
code generation process to produce an adequate makefile.

HTH

Riccardo

Jeremy Goerner

unread,
Mar 6, 2008, 9:21:02 AM3/6/08
to
"Riccardo " <no...@nospam.org> wrote in message <fqoc05
$p5n$1...@fred.mathworks.com>...

>
> Jeremy,
>
> your compilation errors are due to the missing header
files
> in your build process (e.g. uint32_T and other types are
> defined in tmwtypes.h - which may be found in
> <MATLABROOT>\extern\include for my version).
>
> Generally most of those can be found in directories
> included by the Matlab path, although some may get
> generated as well, depending on the version of TMW tools
> and the type of RTW target.
> Typical locations are :
> <MATLABROOT>\extern\include
> <MATLABROOT>\simulink\include
>
> There are several ways of getting hold of those files in
> your build, but perhaps the simplest of all is to stick
the
> relevant search directories into your makefile, so that
> those headers become available.
> Otherwise have a look at the template makefiles (.tmf)
> under <MATLABROOT>\rtw\c\* to get an idea of how to use
the
> code generation process to produce an adequate makefile.
>
> HTH
>
> Riccardo


That did indeed help me a lot. I managed to whiddle the
number of errors down to a consistent 7. All of these
errors are confined to the simstructs.h file. It gives me
the following preprocessor error:

#error Must define one of RT, NRT, MATLAB_MEX_FILE,
SL_INTERNAL, or FIPXT_SHARED_MODULE SAL_API simstruc.h
line 361


How and where do I define RT?

Riccardo

unread,
Mar 6, 2008, 11:45:17 AM3/6/08
to
"Jeremy Goerner" <jdg...@gmail.com> wrote in message
<fqouke$t14$1...@fred.mathworks.com>...

Check in simstruct.h which one is OK for your target.
If I remember correctly, I've always used a flag in the
compiler command line - something like "-DRT" - but this
again may depend on the version of Matlab you're running.

If you can't sort it out, try generating a small test model
with a GRT target, selecting the option "generate code
only", and have a look at the makefile.

0 new messages