- 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.
How to compile Windows generated code on a Linux machine?
129 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 7 Mar 2020
Modificato: MathWorks Support Team
il 20 Ago 2024 alle 8:01
How can I compile code that has been generated on a Windows maching using Simulink Coder, on a Linux machine?
Risposta accettata
MathWorks Support Team
il 20 Ago 2024 alle 0:00
Modificato: MathWorks Support Team
il 20 Ago 2024 alle 8:01
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:
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!