How to use the C code generated from Real time Workshop in Visual Studio?

I have created a very simple add model which takes two constants and returns their sum. Then I generated the C code using Real Time Workshop with grt.tlc as the target by referring to the following link "http://blogs.abo.fi/alexeevpetr/2011/11/18/simplified-building-simulink-generated-c-code-in-visual-studio/ ". I now want to use this code in Visual Studio 2010. But i have more than 300 errors popping up. I followed the approach specified in the link " http://blogs.abo.fi/alexeevpetr/2011/09/30/building-simulink-generated-c-code-in-visual-studio/" But the problem is that i do not have MATLAB installed in the system where the Visual Studio is present. I have however got the .h and .c files required which are mentioned in the link above.I am also new to Visual Studio. Please provide the solution in step wise procedure, so that i can follow it easily.

 採用された回答

Kaustubha Govind
Kaustubha Govind 2012 年 11 月 29 日

0 投票

I think the easiest way is to select the System target file (in the Configuration Parameters window's Code Generation pane) that corresponds to "Create Visual C/C++ solution file" - this should create a Visual Studio project (solution file) that you can directly load into Visual Studio. Alternatively, see Relocate Code to Another Development Environment.

5 件のコメント

archana b m
archana b m 2012 年 12 月 2 日
I created a the visual studio solution. But it gives me the following errors:
1> adder_test.c 1> grt_main.c 1>c1 : fatal error C1083: Cannot open source file: '..\..\..\..\..\..\Program Files\MATLAB\R2012a\rtw\c\grt\grt_main.c': No such file or directory 1> rt_logging.c 1>c1 : fatal error C1083: Cannot open source file: '..\..\..\..\..\..\Program Files\MATLAB\R2012a\rtw\c\src\rt_logging.c': No such file or directory 1> rt_nonfinite.c 1> rt_sim.c 1>c1 : fatal error C1083: Cannot open source file: '..\..\..\..\..\..\Program Files\MATLAB\R2012a\rtw\c\src\rt_sim.c': No such file or directory
It is still trying to access the files from a matlab folder which does not exist on my system. But it exists on the system who created the model. I have these files. But where do i make changes so that it reads from my system?
Kaustubha Govind
Kaustubha Govind 2012 年 12 月 27 日
Ah. If you're relocating to another system, then please read from the link in my answer.
Woody Master
Woody Master 2013 年 5 月 7 日
Hi Kaustubha,
I have a question concerning your first answer to this issue (29 Nov 2012). You said that in the Configuration Parameters
window's Code Generation pane there is an entry like "Create Visual C/C++ solution file". Which version of Matlab/Simulink is
that? Because in my version (R2010a) the only system target files that include something with Visual C/C++ projects are:
"Visual C/C++ Project Makefile only for the "grt" target"
and
"Visual C/C++ Project Makefile only for the Real-Time Workshop Embedded Coder"
I tried it with the first one with the result that a mak-file plus a mk-file were created (besides the usual other files of
course). But with the Visual Studio I can't open such a mak- or mk-file (normally the project files end with vcproj).
Do you have an idea how to come to the project?
Best regards!
Max
Kaustubha Govind
Kaustubha Govind 2013 年 5 月 9 日
編集済み: Kaustubha Govind 2013 年 5 月 9 日
Woody: I think the "Create Visual C/C++ solution file" option was added in R2010b, that's probably why you don't see it.
Dzung
Dzung 2014 年 8 月 27 日
Hi all, can anyone tell me how to setup visual studio and MATLAB/Simulink to do software in the loop simulation?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

質問済み:

2012 年 11 月 29 日

コメント済み:

2014 年 8 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by