1

I have generated one FMU on Windows, and imported the FMU on Mac using Matlab Simulink, and got the following error. I searched for the problem and get some clues from the answer here https://tomlankhorst.nl/quick-fix-matlab-fmu-import-error/, it seems like FMU will be stored as different form when generated on Windows and Mac.

the question is: is it possible to generate a FMU on windows that still works on Mac.

enter image description here

Tao.Y
  • 87
  • 5
  • 1
    Depending on the license you have, you could try to generate a sourcecode FMU, that will be compiled on the target machine directly. Otherwise, cross compilation between Windows/Linux/Mac is tricky. – matth Sep 28 '20 at 09:17
  • Thanks a lot, this makes good sense, at least there is a solution to it. – Tao.Y Sep 29 '20 at 14:02

1 Answers1

7

In order to compile for MacOS, you need the C headers for the MacOS platform. These are only available in XCode which only runs on MacOS and the headers themselves are not allowed to be redistributed.

As such, it's pretty hard to cross-compile for MacOS. You can install XCode on your Mac, move the required headers to your system and compile a Darwin toolchain on your Windows machine (I believe), but it's very error-prone and annoying to update for newer MacOS versions.

The easiest way would be to run MacOS and cross-compile Windows+Linux binaries since these platforms are less closed.

Or like @matth commented, generate a source-code FMU and compile that using the native toolchain on any platform you need.

sjoelund.se
  • 3,468
  • 12
  • 15
  • 1
    thanks a lot, think generate a source-code FMU with specific license may be the best option. – Tao.Y Sep 29 '20 at 14:01
  • 2
    Cross compiling a source-code FMU can be very easily done with fmpy https://github.com/CATIA-Systems/FMPy (which is available for MacOS), e.g., with Tools --> CompilePlatformBinary from the fmpy-gui – Christian Bertsch Sep 29 '20 at 18:12