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.
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?
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.