필터 지우기
필터 지우기

How to compile Windows generated code on a Linux machine?

조회 수: 69 (최근 30일)
How can I compile code that has been generated on a Windows maching using Simulink Coder, on a Linux machine?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 8월 20일
편집: MathWorks Support Team 2024년 8월 20일
You can follow these easy steps to compile Windows generated code on a Linux machine. This has been tested using Generic Real-Time Target (grt.tlc):
1. Navigate to the
Hardware Implementation
pane in the model's Configuration Parameters. There, select 'Device Vendor' to be either 'AMD' or 'Intel' and 'Device Type' to be 'x86-64 (Linux 64)'.
2. Navigate to the
Code Generation
pane. Under 'Build process', enable the options 'Package code and artifacts' and 'Generate Code only'. Also, provide a name in the 'Zip file name' option. This will put all the necessary files needed for compiling in the zip folder. Since only an executable is needed, we can use the Toolchain approach and keep the 'Toolchain' as 'Automatically Installed Toolchain'.
3. Generate C/C++ code from your model (CTRL+B). Then, extract the generated zip folder and navigate inside the folder with the name 'model_grt_rtw'. Here, use the following commands to convert the folder to a flat structure.
>> load buildInfo.mat >> packNGo(buildInfo);
A new folder with the model name will be generated, which will contain all the files generated by packngo in this single folder.
4. Place this folder on a Linux path and do the following operations:
  • Open the 'defines.txt' file in the folder and append the flag '-D' before all the macros, with no spaces between the flag and the macro.
  • Then, remove the spacing between all these macros and put them in a single line.
  • Copy the names of all the source files in the folder and append them to the line with the macros.
The end result will look like this:
-DMODEL=vdp -DNUMST=2 .... vdp.c vdp_data.c classic_main.c
5. Then, from a linux machine where it needs to compiled, call GCC compiler on the above line:
gcc -DMODEL=vdp -DNUMST=2 .... vdp.c vdp_data.c classic_main.c
An executable should be generated (.out file).
The above steps are a simplification of the following documentation which can be accessed by running the below command in the MATLAB command window:
web(fullfile(docroot, 'rtw/ug/relocate-code-to-another-development-environment.html'))
Please follow the below link to search for the required information regarding the current release:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by