Cross-compile for linux with compiler.build.productionServerArchive
조회 수: 10 (최근 30일)
이전 댓글 표시
In Windows Matlab I am building a docker container from a production container that in turn was built from a matlab file that calls a matlab function which runs a simulink model.
prodServerArchive = compiler.build.productionServerArchive(appFile, ...
'ArchiveName',target, ...
'OutputDir',outDir, ...
'Verbose','on');
compiler.package.microserviceDockerImage(prodServerArchive, ...
'ImageName',lower(target));
The compiler.package.microserviceDockerImage (by default? always?) makes use of the WSL2 linux and the docker within.
However, when I query the container when its running it claims the model was built for windows:
{"error":{"id":"simulinkcompiler:runtime:SimulinkCompilerCrossPlatformUnsupported","message":"This deployable was built for architecture: win64, it is unable to simulate on the current architecture: glnxa64. Simulink Compiler deployables are required to be built and run on the same architecture.","stack":[{"file":...mfilen.m","line":<line of simulink call>,...}],"type":"matlaberror"}}* Connection #0 to host localhost left intact
The indicated line seems to point to the simulink model call
so = sim(si);
Why does the productionServer builds after all and does not check if there is a platform incompatibility or better to question, why isn't it platform independent in the first place?
How do I make the compiler.build.productionServerArchive call to cross-compile for linux? Or what is the workflow for compiling on WSL (if that is supported)?
댓글 수: 0
답변 (1개)
Suman
2025년 5월 28일
Hi @Marcus
A compiled MATLAB binary can only be run on machines which match the architecture of the machine that originally compiled the binary. So you need to compile your app on Linux and then that can be used on Windows with WSL to create a docker image.
Also, compiler.build.productionServerArchive does not use WSL and it does not always generate a platform independent binary. You can refer to the limitations of multiplatform portability here: one such limitations is dependencies on Simulink simulations.
I hope this information helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!