How do I cross-compile for Linux on ARM using MATLAB Coder?
조회 수: 16 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2024년 5월 13일
답변: MathWorks Support Team
2024년 6월 4일
I have some MATLAB code that I would like to compile into a ".so" shared library with MATLAB Coder. MATLAB is running on my x86 Windows computer, but I would like the executable to run on an ARM board running Linux. How do generate and compile the code so it will run on the ARM board?
채택된 답변
MathWorks Support Team
2024년 5월 13일
The easiest way to make an executable for ARM on Linux from MATLAB code is to generate code from MATLAB, then copy the generated code to the target device and compile it there.
1. To make a shared library Coder Configuration that targets ARM and uses a portable build system, run the following in the MATLAB Command Window:
>> cfg = coder.config("dll"); % or "exe" for an executable
>> cfg.HardwareImplementation.ProdHWDeviceType = "ARM Compatible->ARM 10"; % or your ARM revision
>> cfg.GenCodeOnly = true;
>> cfg.Toolchain = "CMake";
(your additional configuration)
>> codegen -config cfg myfunction.m
2. Run the following in the MATLAB Command Window to create the archive:
>> load codegen\dll\mytest\buildInfo.mat
>> packNGo(buildInfo, 'packType','hierarchical', 'nestedZipFiles',false)
3. Copy the archive to the target system and extract it. Alongside the extracted folder, create another folder to hold the contents of the build artifacts.
4. On the target system, from the build folder, run the following in the system shell (where "$" represents the shell prompt):
$ cmake ../myproject/codegen/dll/myfunction
$ cmake --build .
For more information about generating and building code with CMake, you can refer to the following documentation page:
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!