How do I use Embedded Matlab Coder to generate C-code?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am doing embedded C-Code generation using Embedded Matlab coder. I tried the Simulink Real-Time Workshop demo:
Demos>Simulink > Real-Time Workshop > Application Samples > Embeddable C-Code Generation Using Embedded MATLAB Coder
However after running:
emlc -T rtw:exe -o rtwdemo_emlcsobel rtwdemo_emlcmain.m stdio.h
I got the error:
??? Build error: Build failed for project "main_rtw". See the target build log for further details. Error in ==> main Line: 1 Column: 1 Compilation failed: Open error report.
I am using 32-bit Matlab R2008a on a Mac.
******* BUILD LOG ********
1 gcc -c -O0 -DUSE_RTMODEL -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-common -no-cpp-precomp -fexceptions -DMODEL=rtwdemo_emlcsobel -DRT -DNUMST=1 -DTID01EQ=0 -DNCSTATES=0 -DUNIX -DMT=0 -DHAVESTDIO -I. -I/tmp/tp9376e37b_e846_409f_ba91_83b4281a6361/emlcdir -I/Applications/MATLAB_R2008a/simulink/include -I/Applications/MATLAB_R2008a/extern/include -I/tmp/tp9376e37b_e846_409f_ba91_83b4281a6361/emlcdir/emcprj/rtwexe/rtwdemo_emlcmain -I/tmp/tp9376e37b_e846_409f_ba91_83b4281a6361/emlcdir main.c
2 In file included from main.c:11:
3 main.h:13:18: error: math.h: No such file or directory
4 main.h:14:20: error: stdlib.h: No such file or directory
5 main.h:15:20: error: string.h: No such file or directory
6 In file included from /usr/llvm-gcc-4.2/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15,
7 from rtwtypes.h:21,
8 from main.h:18,
9 from main.c:11:
10 /Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:15:25: error: no include path in which to search for limits.h
11 main.c:13:19: error: stdio.h: No such file or directory
12 main.c: In function 'main':
13 main.c:40: error: 'FILE' undeclared (first use in this function)
14 main.c:40: error: (Each undeclared identifier is reported only once
15 main.c:40: error: for each function it appears in.)
16 main.c:40: error: 'eml_fid' undeclared (first use in this function)
17 main.c:65: warning: incompatible implicit declaration of built-in function 'fwrite'
18 main.c: In function 'm_refp1_sqrt':
19 main.c:177: warning: incompatible implicit declaration of built-in function 'sqrt'
20 gmake: *** [main.o] Error 1
21
Could this be because I have XCode 4.0 installed? I check mex.getCompilerConfigurations() and it says it is using GNU g95. I am currently downloading XCode 3.0 to see if that helps.
----------
I tried running the same demo on a windows machine (64 bit R2010a) - I got a different error (do not have the error message) - it was something along the lines 'Could not locate MEX compiler options file mexopts.bat'. When I run mex -setup, it shows 0 compilers when I try to automatically locate a compiler. I have Visual Studio 2010 Express installed on this computer. I am currently downloading Visual Studio 2008 Express, because it looks like R2010a Simulink does not support 2010 Express (<http://www.mathworks.com/support/compilers/R2010a/win64.html)>.
Any help getting either of these issues sorted out would be appreciated.
Om
1 comentario
Kaustubha Govind
el 8 de Jul. de 2013
Please paste the target build log messages for the first case (the "Open error report" message should be a link that opens up the log). For the second case, make sure that you install a supported compiler and try again.
Respuesta aceptada
Ryan Livingston
el 8 de Jul. de 2013
If you have a look at the supported compilers for R2008a:
you will notice that XCode is necessary for using Embedded MATLAB. If you run:
mex -setup
in that MATLAB can you choose XCode as your compiler, does the code compile?
Más respuestas (1)
Om
el 10 de Jul. de 2013
1 comentario
Kaustubha Govind
el 10 de Jul. de 2013
Om: The issue seems to be that your compiler cannot find standard libraries. What if you modify yprime.c to include stdlib.h and attempt to use a function from that library? Does it still compile with the MEX command?
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!